[whatwg] Proposal for separating script downloads and execution
nzakas at yahoo-inc.com
Tue Feb 1 09:53:31 PST 2011
Each of the existing solutions shifts around when download and execution happens by giving developers control over when the download occurs but only minimally when execution happens. As a result, developers have created ever more ingenius/fragile solutions to allow the separation of script downloads and execution. Examples:
2. ControlJS (http://stevesouders.com/controljs/) by Steve Souders, which extends Stoyan's model to allow on-demand execution of scripts.
The ability to separate download and execution is a trend that has not only emerged, but continues to be explored. There are problems with the previous solutions, the biggest of which (in the case of #1 and #2) is the reliance on the browser caching behavior which may, in some instances, lead to a double download of the same script. It would be preferable for a standardized approach to achieve these goals.
Overview of Proposal:
Add a new attribute to the <script> called noexecute (for lack of a better term) that instructs the browser to download the script but do not execute it. Developers must manually execute the code by calling an execute() method on the script node. Simple example:
var script = document.createElement("script");
script.noexecute = true;
script.src = "foo.js";
Because there are a lot of nuanced changes to <script> as a result of this proposal, I've written up a full description here:
I'd love some feedback on whether or not this a) makes sense and b) is feasible.
Commander Lock: "Dammit Morpheus, not everyone believes what you believe!"
Morpheus: "My beliefs do not require them to."
More information about the whatwg