Live data from Hacker News

How make your web-app become available faster: Let go of the DOM Ready events

thanpol.as

1–10 of 20 posts

Re: How make your web-app become available faster: Let go of the DOM Ready events

#3

Consider'd: http://javascriptisawesome.blogspot.com/2011/07/faster-than-... ?

It should be noted that the event used in that, DOMNodeInserted, is deprecated: http://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeI...

Re: How make your web-app become available faster: Let go of the DOM Ready events

#4
post #3

Consider'd: http://javascriptisawesome.blogspot.com/2011/07/faster-than-... ?

It should be noted that the event used in that, DOMNodeInserted, is deprecated: http://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeI...

Ah, good point!

Re: How make your web-app become available faster: Let go of the DOM Ready events

#6
This would require some discipline in a shop using this. For one thing, one would want to have a convention where write() is not used or perhaps is disabled until the operation is safe. Also, this may be a form of optimization which is applied based on profiling. An app would benefit most from this on the pages most frequently viewed the earliest. ROI would increase for mature code which is changing less frequently.

Re: How make your web-app become available faster: Let go of the DOM Ready events

#7
So as a summary, Javascript loaded (except for loaded via document.write) can immediately access the DOM if the Javascript is loaded in the bottom of the body-element making the use of a ready-event like jQuery's ready-event obsolete. I have always wondered if that really is the case but haven't tried it out myself, seems that it's a green light then. :-)

Re: How make your web-app become available faster: Let go of the DOM Ready events

#9
An important caveat to the "load scripts at the end of the document technique": The visual elements of a page will render before the functional components (i.e., JavaScript) are available.

Imagine a site the sets a custom `submit` handler for a `` tag, possibly for client-side form validation, an AJAX file uploader, date selection, etc. A user submits the form before JavaScript has loaded completely and doesn't get the benefit of the JavaScript-enhanced experience. In local development or on a high-speed connection this will probably never happen. But a user accessing the site with their phone over the slow U.S. cell data network has a much higher chance of hitting upon this undesired behavior.

Post reply on HN