preload script while execute in order, when DOMContentLoaded is called.
The test under web folder ( 20 requests, 533kB resources ) contains test with scriptloader and synchronous tags. Their results:
tag:DOMContentLoaded~Load. ( 670ms )tagwithdefer: similar totag.scriptloader:DOMContentLoaded(588ms) faster thanLoadby ~ 80ms (666ms)
where
DOMContentLoaded: DOM is ready, so the handler can lookup DOM nodes.Load: external resources are loaded, so styles are applied, image sizes are known etc.
scriptloaderis faster inDOMConentLoaded, because it defers script executing afterDOMContentLoaded.scriptloadermay be used to control cache of js files.