4 ms·
Honestly, I don't like claims like this that are offered without any support. Why shouldn't I wait for the DOM to be ready? Am I losing performance? If so, wher
by javajosh 14y ago
Honestly, I don't like claims like this that are offered without any support. Why shouldn't I wait for the DOM to be ready? Am I losing performance? If so, where are the benchmarks?
Frankly, I'm surprised a casual comment on G+ is getting any traction whatsoever on HN.
- mattmanser 14y agoThe DOM loaded event can take a while to fire, there's no need to wait for it but then you end up either sprinkling your html with script tags or firing a script just before the end body tag. i.e. maintenance nightmare for the former, what's the point for the latter? Neither much better than just waiting for dom loaded. If it is taking a while to fire, better to solve that problem than piss around with a half built page in my experience. I experimented at one point with js enhancing controls just after they were declared, it's honestly not worth the effort. He'll learn. This smacks of the bootstrap semi-colon nonsense, we all tried semi-colonless once, it ends up a nightmare, but some mistakes the next generation need to figure out themselves.
- barclay 14y ago> better to solve that problem than piss around with a half built page in my experience. Seconded. This can cause far more bugs and timing problems than it's worth. Find out what's taking so long to fire, and fix (or defer) that.
- kevingadd 14y agoYeah, whether or not you can run stuff before DOM ready is often one of those questions where most answers are right 99% of the time and piss off your customers the other 1% of the time. Have fun debugging your little optimization when you literally can't reproduce the bug in your own debugging environment.
- mkmcdonald 14y ago> [on placing a script before the end tag of the body element] what's the point [...]? Neither much better than just waiting for dom loaded. I'll take sane, library-agnostic script without event listeners for $500, Alex.
- crazygringo 14y agoIn my experience, the main reason is any ad content you're serving. If an ad network's content times out (which I've seen happen for hours at a time, multiple times a year), your page might take 30 seconds until it fires the DOM ready. At one company I worked at, the ad network we used got so bad that we not only executed all our JavaScript at the bottom of every page (instead of in the DOM ready), but also only loaded the ads after that, and then dynamicaly repositioned them to the "inline" spots where they supposed to appear.
- pestaa 14y agoI wonder if post-loading ads is allowed in most TOSes. If I were in their shoes, I would not like it.
- cheatercheater 14y agoThe supporting information was supplied with the claim. You wait for items irrelevant to your applications to (very sluggishly) load. I suggest reading the book "High performance websites", it's very thin.
- ma2rten 14y agoI agree, I also don't like claims that it impacts performance to unnecessarily wait for the CSS to download without any benchmarks. I also don't like it when people say that exponential time algorithms take longer than polynoinal time algorithms without showing benchmarks.