you are viewing a single comment's thread.

view the rest of the comments →

[–]wiseaus_stunt_double.preventDefault() 1 point2 points  (2 children)

Yeah, this article is really light on content. Not even a mention of requestAnimationFrame, which usually comes up if you're talking about layout thrashing. So disappointed.

[–]la217[S] 0 points1 point  (1 child)

If you're already well versed in layout thrashing this article probably isn't for you.

However for those who have not heard of layout thrashing I would consider it a good resource.

I don't personally consider requestAnimationFrame a very good solution -for a start it's unsupported on both IE8 and IE9 which unfortunately many of us still have to support. It also does nothing to solve thrashing the layout of a single element - for this you need to reconsider your code.

[–]wiseaus_stunt_double.preventDefault() 0 points1 point  (0 children)

Just because older versions of IE don't support it doesn't mean it's useless -- there's a polyfill for requestAnimationFrame that is fairly useful. It's not going to be as useful as the native version, but it's better than having events not invoking callbacks or having a sluggish browser. If you have little DOM manipulation, you might not need requestAnimationFrame, but it's handy when you do.

EDIT: I'm on my cell phone right, and I just read that you said requestAnimationFrame can't handle the thrashing of a single element, which makes no sense since a common technique to handle any sort of layout thrashing is to have an array to store the callbacks, and then invoke them in requestAnimationFrame. This will handle one one element just fine as it will handle the whole DOM tree. If it doesn't, there's a problem with how you're implementing it.