[whatwg] Script preloading, optional dependencies

Kornel Lesiński kornel at geekhood.net
Sun Jul 14 07:00:43 PDT 2013

On Fri, 12 Jul 2013 21:20:57 +0100, Kyle Simpson <getify at gmail.com> wrote:

> So, just to clarify, `<script dependencies=…>` waiting on some other  
> <script> tag is ONLY waiting on that script tag loading to have some  
> sort of positive network result, whether that be a 2xx, 3xx, 4xx, or  
> 5xx, and it cares not whether the script in question actually loaded,  
> nor whether it fired its `onerror` event? Do I have that correct?

What should happen is an interesting question.

If execution continued when dependency fails to load/parse, then later  
scripts could try to recover/use fallback/run with reduced functionality  
(e.g. if jQuery plugin for fancy animations fails to load the application  
can disable fancy animations and run anyway).

OTOH aborting execution of the rest of the dependency chain is probably  
what most developers expect, and it often makes sense as most scripts  
without dependencies met will fail.

So maybe a concept of optional dependency would be useful?

e.g. error handler could signal somehow that execution should continue:

     <script id="fancy-animations" src="//flaky.cdn/js" onerror="return  
false;" />

or there could be a microsyntax in dependencies:

     <script dependencies="fancy-animations? required-stuff" />


     <script id="fancy-animations-cdn" src="//flaky.cdn/js" />
     <script id="fancy-animations-local" src="/fancy-animations-copy.js" />
     <script id="nothing" />
     <script dependencies="(fancy-animations-cdn or fancy-animations-local  
or nothing) required-stuff" />

regards, Kornel

More information about the whatwg mailing list