Hacker Newsnew | past | comments | ask | show | jobs | submit | benlinton's commentslogin

While we probably shouldn't worry about long CSS selectors due to performance issues, we should avoid them for other reasons.

For instance, because it's considered a best practice to avoid "Modifying Components Based On Who Their Parents Are". Please see this article: http://engineering.appfolio.com/2012/11/16/css-architecture/


As far as I know, you should still use document ready. Putting javascript at the bottom does not ensure the dom is loaded before the javascript executes. Most of the time it probably is, but it's definitely not a certainty.

And not all javascript goes at the bottom, only deferable javascript belongs there. The problem caused by scripts is that they block parallel downloads. To prevent that we put as many at the bottom as is possible. But some still belong at the top if they're non-deferable; in otherwords if they should load before the dom (e.g. modernizr).

As an added fun fact: In every scenario all external CSS should load before all javascript because CSS doesn't block parallel downloads. And page display should be top priority in the load order.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: