News for hackers. Stuff that matters.
Re:Preventing 'layout thrashing' by nsxwolf on Saturday October 05, 2013 @03:03PM (#6501654)
There doesn't seem to be a definition of layout thrashing anywhere on the internet. Googling "what is layout thrashing" returns nothing.

Anyone want to offer the net's very first ever explicit definition of this term?

Re:Preventing 'layout thrashing' by nostrademons on Saturday October 05, 2013 @03:07PM (#6501669)
When interleaved DOM queries and modifications in your JS cause the DOM to be successively invalidated and then laid out again, multiple times within a single script.

Modern browsers use a dirty-bit system for DOM modifications: they don't perform a layout every time it's changed, they just note the change and then perform the layout when the script returns. However, if the DOM is queried in the meantime, they have to perform layout, because otherwise they won't have up-to-date dimensions and positions. So if you interleave queries with modifications, the dirty bit gets set, the DOM gets laid out, the dirty bit gets set, the DOM gets laid out, etc, defeating all the optimizations browser vendors have put in place.

Layout is an expensive operation, too - on a moderately complex website like Google Search it takes about 17ms on desktop, and that can increase by 10x on mobile devices. 170ms is well past the point of visual perception.

Re:Preventing 'layout thrashing' by judk on Saturday October 05, 2013 @05:17PM (#6502113)
> on a moderately complex website like Google Search

Oh how times have changed.

Re:Preventing 'layout thrashing' by nsxwolf on Saturday October 05, 2013 @03:55PM (#6501833)
Thank you.
Re:Preventing 'layout thrashing' by kellegous on Saturday October 05, 2013 @07:53PM (#6502528)
I may be responsible for the term "layout thrashing" and tried to explain it in a blog post a while back: http://kellegous.com/j/2013/01/26/layout-performance/
Re:Preventing 'layout thrashing' by rmrfrmrf on Saturday October 05, 2013 @03:19PM (#6501713)
It's not a formal term; the author was just drawing the parallel between memory + disk thrashing and the DOM + layout thrashing. Basically slowdown due to excessive reads and writes/redundantly moving data back and forth.
Re:Preventing 'layout thrashing' by dminor on Saturday October 05, 2013 @06:40PM (#6502347)
People have called it other things in the past. Google calls it "redundant layout" in this article: https://developers.google.com/web-toolkit/speedtracer/speed-...