- From: Garrett Smith <dhtmlkitchen@gmail.com>
- Date: Mon, 15 Nov 2010 20:23:56 -0800
On 11/15/10, Juriy Zaytsev <kangax.dev at gmail.com> wrote: > When removing [1] a long-loading script element from a document, browsers > seem to disagree on whether such removal should affect page rendering. A > simple test ? > http://kangax.github.com/jstests/blocking_script_removal_test/? > shows that Opera (9.x - 11) and IE (5.5 - 9) immediately continue > parsing > the document upon element removal. However, in Firefox (3-4) and Chrome (9) > the document parsing is blocked until script is loaded or times out (even > when the actual element no longer exists in the document, has its "src" > reference an empty string, and there exist no references to it). > > Does current draft explain what should happen in such case, and if it does ? > what is it (I can't seem to find it)? This seems to be the relevant part of the spec, and it does not address your case: http://dev.w3.org/html5/spec/Overview.html#already-started Though there are a few questions there. | When a script element that is not marked as being | "parser-inserted" experiences one of the events listed | in the following list, I think what was meant was "... _any_ one of the following conditions is met, ..." | * The script element gets inserted into a document. | * The script element is in a Document and its child nodes are changed. For any script, including external? | * The script element is in a Document and has a src | attribute set where previously the element had no such attribute. For any script, including one with script content? The existing discrepancy suggests that > it's something worth codifying. > Regarding removal, I recall a version of Opera where removing the script element of an external script that was not already started would cause the script to not be evaluated. Nice feature, but not interoperable and so totally impractical as far as web scripting goes. > [1] Where "removing" is done through scripting (say, via Node's > `removeChild` or analogous method). > innerHTML might be a good choice, to avoid memory leads in a few browsers (ala Dojo's "garbage bin" technique). Front end developers at Google prefer to first to set the script's src to `null`: <http://googlecode.blogspot.com/2010/11/instant-previews-under-hood.html> Though what that accomplishes, I have no idea. Garrett
Received on Monday, 15 November 2010 20:23:56 UTC