Hacker News new | ask | show | jobs
by bluesmoon 4905 days ago
hi josh,

as one of the people responsible for publishing those rules, I feel obligated to mention that they're somewhat out of date. The more correct rule today, given browser enhancements is, "It depends".

Asynchronously loaded code is obviously better. Stick it into the head, and allow it to download in parallel with the rest of the page. It doesn't need to execute until much later, but it's the downloading and parsing that takes the most time, so get that out of the way as soon as possible.

Within your script, you can check for the existence of the elements you need to manipulate. YUI does this quite well, but if you're using something else, just poll infrequently for the nextSibling of the node you want.

1 comments

Philip, thanks for jumping in and well said. Looking at the state of the web right now where a typical site might have a couple dozen CSS/JS files, I think the rules are still well worth evangelizing. We still have a long way to go in helping people understand the fundamental principles, even if the exact implementations change over time.