6 ms·
Why do you still need a document ready function if all your scripts are loading after the html anyway?
by Yahivin 15y ago
Why do you still need a document ready function if all your scripts are loading after the html anyway?
- deleted 15y ago[deleted]
- sams99 15y agowell its more of a legacy problem, we are used to using it everywhere, deferring external scripts is a fairly easy exercise but those tiny snippets everywhere that have $(doStuff) are more annoying to port
- ehynds 15y agoIf all your scripts are before the closing </body>, the DOM will be ready by the time they execute, and you can safely ditch your legacy ready wrappers.
- beaumartinez 15y agoThe DOM will have been parsed if your scripts are at the end—but external components (links, imgs) may not have loaded yet.
- ehynds 15y agoThe same is true whether or not you use a document.ready statement; you're thinking of window.onready, which fires once all images have been downloaded.
- beaumartinez 15y agoYou are correct! Thanks. Been spending too long with document.readyState.
- ricardobeat 15y agoyou meant window.onload