Hacker News new | past | comments | ask | show | jobs | submit login

The 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.




> 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.


> [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.


Yeah, 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.




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

Search: