W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2013

Re: [whatwg] Script preloading, optional dependencies

From: Kornel Lesiński <kornel@geekhood.net>
Date: Sun, 14 Jul 2013 15:00:43 +0100
To: whatwg@lists.whatwg.org
Message-ID: <op.wz7s7himte2ec8@aimac>
On Fri, 12 Jul 2013 21:20:57 +0100, Kyle Simpson <getify@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" />

or:

     <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
Received on Sunday, 14 July 2013 14:01:16 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:03 UTC