[whatwg] Deferred Javascript parsing

David Bruant bruant.d at gmail.com
Mon Apr 29 13:43:35 PDT 2013


Le 29/04/2013 22:21, Benjamin Stürmer a écrit :
> I have been reading about a technique described here (
> http://googlecode.blogspot.de/2009/09/gmail-for-mobile-html5-series-reducing.html)
> for deferring the parsing of scripts until they are actually required. This
> can be a useful technique for allowing lazy-loading of script without AJAX.
> A common method used to achieve this (the method described in the linked
> article) is commenting-out blocks of code and then uncommenting it and
> running it via eval(), which is obviously not an ideal solution.
>
> Has there been any consideration given to an attribute to mark a script tag
> as "do not parse or execute" until it's been triggered?
I think if you put any invalid value in the "type" attribute of the 
script element, then, the element won't be parsed nor executed. If your 
script element has a given id, you can easily find the code 
(document.getElementById(id).textContent) and eval it.

David



More information about the whatwg mailing list