[whatwg] Proposal for change in recommendation for loading behavior of non-applicable stylesheets

Scott Jehl scott at scottjehl.com
Mon Jun 11 14:17:57 PDT 2012


Thanks again, Boris.

These are fair answers, but I can't help but think that the problem is critical enough to warrant spec-level consideration. 

As device contexts are increasing, authors are referencing more stylesheets to address them, and the existing behavior across most browsers ensures that every last byte of those stylesheets will be loaded - often in a synchronous/blocking manner. This is less about author convenience and more of a benefit to users: deferring the load of inapplicable stylesheets would surely have a large impact on perceived page performance. I'd be happy to provide some demos of existing sites with my shim included for profiling sake.

Further, judging by the response received on twitter when I posted that research last week, I think the current behavior is not at all what most authors expect to happen. But we also don't really have any other options aside from using JavaScript to make it work the way it seems like it really should. 

I think you've rightfully pointed out that the lazy-loading idea probably won't fly with vendors and could even cause problems in certain cases.  In the past, there were similar concerns for @media print stylesheets, which are always requested (like all other non-applicable media) up-front, perhaps in the off-chance that connectivity would be lost when the user tries to print. That's at least the reasoning I'd seen cited before, and that behavior led to authors embedding @media print styles inside their @media all stylesheet just to prevent that HTTP overhead.

Unfortunately, these days inlining every media query does nothing to solve this problem, aside from reducing HTTP requests by shifting all our weight into a single heavy request.

Even assuming that implementing this feature would mean delaying CSS prefetching until the metaviewport tag was parsed, wouldn't the tradeoff in page loading speed be worth it? I'd imagine many pages could have several fewer blocking requests as a result.

Thanks again and if you feel this isn't the proper forum for addressing this issue, do you have any suggestions where I should take it?

Scott


More information about the whatwg mailing list