[whatwg] Script-related feedback

Ian Hickson ian at hixie.ch
Wed Jul 24 11:18:01 PDT 2013

On Wed, 9 Jan 2013, Anne van Kesteren wrote:
> On Wed, Jan 9, 2013 at 9:32 PM, Ian Hickson <ian at hixie.ch> wrote:
> > Advantages of putting this in JS over multipart:
> >
> >  - it's backwards-compatible
> >  - it's easier to parse a static barrier than a multipart/*'s wacky
> >    syntax.
> >  - it doesn't impact any of the current fetching logic, since it's
> >    still just one resource instead of introducing a layer in between
> >    <script>'s logic and the JS logic.
> >  - it automatically works anywhere you can use JS, not just where HTTP is
> >    involved.
> >  - it can be shimmed more easily (if you trust the JS not to have
> >    arbitrary injection and be written with the shim in mind, especially).
> >  - it doesn't run into weird problems like what if a part has the wrong
> >    MIME type.
> >  - it's way easier to deploy (authors hate having to set MIME types).
> >  - it doesn't run into the problem that all UAs have historically ignored
> >    the MIME type of script.
> Adding magic meaning to certain JavaScript comments seems like a pretty 
> big downside though. Furthermore, multipart logic, however weird, is a 
> sunk cost both on consumer and producer side, whereas introducing 
> /*@BREAK*/ seems like a very steep uphill battle. And actually <img> is 
> a precedent for checking a MIME type before sniffing/executing and it 
> hasn't been much of a problem. (The problems there were mostly figuring 
> out how SVG should work.)

Yeah, but the multipart logic has pretty big disadvantages -- mainly the 
opposite of the advantages for a built-in feature:

 - not backwards compatible
 - not as simple to understand, use, implement, or spec
 - doesn't really work outside HTTP
 - harder to shim
 - more edge cases to define (e.g. what if the MIME types of the parts 
   change unexpectedly)
 - requires setting MIME types, which authors hate

I think JavaScript would be the logical place to support this. We don't 
use multipart/* logic to do incremental rendering of HTML, we don't use it 
for incremental rendering of images (only for animating them), why would 
we use it for incremental execution of script? I think scripts, just like 
image formats, HTML, XML, etc, should have built-in support for 
incremental processing.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the whatwg mailing list