New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 792038 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner:
Last visit > 30 days ago
Closed: Jan 2018
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

rel=preload links do not download if media type does not match

Reported by sc...@filamentgroup.com, Dec 5 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:57.0) Gecko/20100101 Firefox/57.0

Steps to reproduce the problem:
1. Reference a CSS file with <link rel=preload href=mycss.css media="(min-width: 800px)" onload="this.rel='stylesheet'> 
2. Load page at a viewport size narrower than 800px
3. The stylesheet file will not be downloaded. (It also will not download if the browser is later resized to a viewport size wider than 800px).

Simple demo page is here: https://254-origin-loadcss.fgview.com/test/preload-control.html

What is the expected behavior?
It's unclear if this is the expected behavior, but our assumption was that the link will download (but not necessarily apply) regardless of whether the media matches, much like a rel=stylesheet link will. 

What went wrong?
The link did not cause the resource to fetch.

Did this work before? N/A 

Does this work in other browsers? N/A

Chrome version: 62.0.3202.94 (Official Build) (64-bit)  Channel: stable
OS Version: OS X 10.12
Flash Version: Shockwave Flash 27.0 r0

The spec doesn't seem completely clear on what the behavior should be for non-matching media links both at load and later in the session when the media matches.
 

Comment 1 by y...@yoav.ws, Dec 5 2017

Not preloading the resource when the media does not match is intended behavior to enable "responsive preloading".
The spec bits at https://html.spec.whatwg.org/multipage/semantics.html#processing-the-media-attribute apply, but maybe we should add a note about it to the preload spec.

OTOH, the resizing bit should work, and if the media matches at a later phase, the resource should preload. That seems like a bug (even if it's not clearly stated in the processing model AFAICT)
A note is probably good, yeah, just to remind people.

I do agree with this behavior in general — the `media` attribute is operating on the correct level. The "correct" code would be:

<link rel=preload href=mycss.css onload="this.rel='stylesheet'; this.media='(min-width: 800px)'">

Comment 3 by kochi@chromium.org, Dec 27 2017

Owner: y...@yoav.ws
Status: Assigned (was: Unconfirmed)
Yoav, could you work on this (adding a note to the spec)?

Comment 4 by y...@yoav.ws, Dec 27 2017

Yeah, I'll add a note.

Comment 5 by y...@yoav.ws, Jan 9 2018

Status: WontFix (was: Assigned)
Added a note: https://github.com/w3c/preload/pull/117
Closing as WontFix

Sign in to add a comment