Enable <link rel=preload> support by default
Categories
(Core :: Networking, task, P2)
Tracking
()
People
(Reporter: mayhemer, Assigned: emilio)
References
(Blocks 1 open bug)
Details
(Keywords: dev-doc-needed, Whiteboard: [necko-triaged] [platform-rel-Wikipedia] )
Attachments
(1 file)
48 bytes,
text/x-phabricator-request
|
jcristau
:
approval-mozilla-beta+
|
Details | Review |
This just means to flip the network.preload
preference to true
.
Depends on stability, integrity and performance testing.
Updated•4 years ago
|
Updated•4 years ago
|
Comment 1•4 years ago
|
||
I wonder how prevalent this pattern is already:
<link rel="preload" as="style" onload="this.rel = 'stylesheet'" href="scripts/bootstrap/css/bootstrap.css">
![]() |
Reporter | |
Comment 2•4 years ago
|
||
(In reply to Mike Taylor [:miketaylr] from comment #1)
I wonder how prevalent this pattern is already:
<link rel="preload" as="style" onload="this.rel = 'stylesheet'" href="scripts/bootstrap/css/bootstrap.css">
With the patches for "preload as speculative load" this works. But it's hugely suboptimal because it's adding an unprioritized loop to the event queue that blocks the stylesheet from being applied and the engine to know there will be a style applied and optimize for it. Leaving rel at "stylesheet" is performing way better. Unless this has to be some kind of a lazy load; but that then defeats the purpose of preload which is about prioritization. It's like using express delivery and then leave the package for two days at your doorstep.
In other words: don't use this construct unless you really know what you are doing. I don't :)
Updated•4 years ago
|
Comment 4•4 years ago
|
||
See Also: → https://webcompat.com/issues/51983
Another top site using this pattern (ranks #85 in Turkey)
<link rel="preload" href="https://cdn.pr.trt.com.tr/static/font/fontawesome/css/all.min.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
I see this on stackoverflow (but it does note that it won't work in Firefox, assuming people even read (or care...)): https://stackoverflow.com/a/46750893
Comment 5•3 years ago
|
||
One more site with a similar pattern <link rel="preload" href="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
Comment 6•3 years ago
|
||
Found my way here trying to see why this WP plugin example page was looking broken in FF. The owner fixed it for now, but not sure if lazy loading still works with that fix in place.
Hi devs!
My website does not look good in firefox either, because the new default functionality in firefox is not active, my website is https://www.convertidor.es thanks
Assignee | ||
Comment 8•3 years ago
|
||
(In reply to Jesús from comment #7)
Hi devs!
My website does not look good in firefox either, because the new default functionality in firefox is not active, my website is https://www.convertidor.es thanks
Why not just using <link rel="stylesheet">
? Using <link rel="preload" as="style" onload="this.onload=null;this.rel='stylesheet'">
is not great, you should either have both the <link rel="preload">
and <link rel="stylesheet">
, or just the later I guess. And you're putting <link rel="stylesheet">
in a <noscript>
tag, so you can just remove the <noscript>
basically.
(In reply to Emilio Cobos Álvarez (:emilio) from comment #8)
(In reply to Jesús from comment #7)
Hi devs!
My website does not look good in firefox either, because the new default functionality in firefox is not active, my website is https://www.convertidor.es thanks
Why not just using
<link rel="stylesheet">
? Using<link rel="preload" as="style" onload="this.onload=null;this.rel='stylesheet'">
is not great, you should either have both the<link rel="preload">
and<link rel="stylesheet">
, or just the later I guess. And you're putting<link rel="stylesheet">
in a<noscript>
tag, so you can just remove the<noscript>
basically.
Thanks.
Because I think that is not good for Google.
Assignee | ||
Comment 10•3 years ago
|
||
Why not? It shouldn't cause any extra load.
Comment 11•3 years ago
|
||
(In reply to Emilio Cobos Álvarez (:emilio) from comment #10)
Why not? It shouldn't cause any extra load.
As I see the feature is available but it is not enabled by default in Firefox because it is being verified and tested
This feature is good for Google.
Assignee | ||
Comment 12•3 years ago
|
||
(In reply to Jesús from comment #11)
(In reply to Emilio Cobos Álvarez (:emilio) from comment #10)
Why not? It shouldn't cause any extra load.
As I see the feature is available but it is not enabled by default in Firefox because it is being verified and tested
This feature is good for Google.
I mean that instead of having:
<link rel="preload" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" integrity="sha256-l85OmPOjvil/SOvVt3HnSSjzF1TUMyT9eV0c2BzEGzU=" crossorigin="anonymous" as="style" onload="this.onload=null;this.rel='stylesheet'"/>
<noscript><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" integrity="sha256-l85OmPOjvil/SOvVt3HnSSjzF1TUMyT9eV0c2BzEGzU=" crossorigin="anonymous" /></noscript>
You could have:
<link rel="preload" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" integrity="sha256-l85OmPOjvil/SOvVt3HnSSjzF1TUMyT9eV0c2BzEGzU=" crossorigin="anonymous" as="style" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" integrity="sha256-l85OmPOjvil/SOvVt3HnSSjzF1TUMyT9eV0c2BzEGzU=" crossorigin="anonymous" />
And it'd work in all browsers, and get the benefit on <link rel="preload">
in Chrome as well (so no downside).
Comment 13•3 years ago
|
||
Ok thanks i will try
![]() |
Reporter | |
Comment 14•3 years ago
|
||
Thanks for the interest in this feature. But please bring these issues and discussions to web development forums instead of a polluting a mozilla bug with it. Thanks.
Comment 15•3 years ago
|
||
Sorry,
Where is a discussions forums to web development ?
Thanks.
![]() |
Reporter | |
Comment 16•3 years ago
|
||
(In reply to Jesús from comment #15)
Sorry,
Where is a discussions forums to web development ?
Thanks.
I think there is https://chat.mozilla.org/#/room/#front-end-web-development:mozilla.org where you should be able to discuss these issues.
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Comment 18•3 years ago
|
||
When will we can use <link rel="preload"> on Firefox?
Comment 19•3 years ago
|
||
The last experiment to confirm that we do not have any regressions is running. I hope it will went well and we will enable rel=preload in Firefox 84.
Comment 20•3 years ago
|
||
Hi. I noticed https://blog.mozilla.org/performance/2020/12/15/2020-year-in-review/ noting that rel-preload is shipped in Firefox 84. And I see network.preload
set to true after updating to 84.
Does that mean it's shipped in release? If so, it's great and worth mentioning in developer notes as well.
Comment 21•3 years ago
|
||
As far as I can tell preload didn't make it to Firefox 84:
network.preload
isfalse
for me- I also don't observe preloads working in WebPageTest with Firefox 84
- our RUM data for Fx83 and Fx84 show no change, and if preload was enabled, I'd expect big improvements
Having said that I see that Firefox Dev Edition 85 has the flag enabled.
Updated•3 years ago
|
Comment 22•3 years ago
|
||
network.preload is true for me (and my customers...).
However, with a media tag of "print" it is causing an endless looping error for me. I am using the onerror attribute to try and append an alternate URL if the first fails to load. This is always getting triggered, and the onerror is looping when I append another link to the head. But it only happens with the media tag of "print"; screen and not defined works fine. Onload also is never called.
I've been able to work around this by changing my JS to only add another link tag if one doesn't already exist with that URL. But it sucks that I had to do that.
So... if I'm an idiot and did something wrong, please let me know. But it's been working for a while and only quit working upon upgrading recently. I know 84.0.2 causes this problem, maybe 84.0.1, too, not sure.
<link href="https://sparqlogon.azureedge.net/SharedContent/styles/Print.1.1.css" onerror="this.onerror=null;window.useBackupCssUrl('https://logon.sparqdata.com/SharedContent/styles/Print.1.1.css')" as="style" onload="this.onload=null;this.rel='stylesheet'" media="print" rel="preload" type="text/css">
Assignee | ||
Comment 23•3 years ago
|
||
Can you attach a complete test-case which doesn't work in a new bug?
Comment 24•3 years ago
|
||
Assignee | ||
Comment 25•3 years ago
|
||
Afaict we've shipped this code via normandy or what not, so let's do
this.
Updated•3 years ago
|
Comment 26•3 years ago
|
||
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e205e7b4a73c Toggle the network.preload pref on on all channels. r=dragana
Assignee | ||
Comment 27•3 years ago
|
||
Eric, AIUI the normandy recipe should only be enabled for 84. Should this patch be uplifted to beta 85 so that we don't ship, then unship, then ship the feature?
Comment 28•3 years ago
|
||
Emilio, yes, the recipe is currently set to enable only for 84. Two options to avoid unshipping: 1) uplift the patch to 85, or 2) update the recipe to include 85 and let the patch ride the train.
Assignee | ||
Comment 29•3 years ago
|
||
Comment on attachment 9196197 [details]
Bug 1626997 - Toggle the network.preload pref on on all channels. r=dragana
Beta/Release Uplift Approval Request
- User impact if declined: We'd unship preload in 85 which seems unfortunate.
- Is this code covered by automated tests?: Yes
- Has the fix been verified in Nightly?: No
- Needs manual test from QE?: No
- If yes, steps to reproduce:
- List of other uplifts needed: None
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky): We've shipped this pref flip in 84 via normandy.
- String changes made/needed: none
Comment 30•3 years ago
|
||
bugherder |
Comment 31•3 years ago
|
||
the rollout (https://normandy.cdn.mozilla.net/api/v3/recipe/1102/) is currently at 50%. Are we happy for that to go 100% with the 85 release?
Comment 33•3 years ago
|
||
Comment on attachment 9196197 [details]
Bug 1626997 - Toggle the network.preload pref on on all channels. r=dragana
approved for 85.0b9
Comment 34•3 years ago
|
||
bugherder uplift |
Comment 35•3 years ago
|
||
FYI this feature got documented in FF85 as Web technology for developers > HTML: HyperText Markup Language > Preloading content with rel="preload". Can you please provide advice about the section/example on including a mime type.
The example in that section specifies two links to preload sintel-short.mp4 and sintel-short.mp4. Later on in the body the <video controls>
provides both files as sources. Without preloading the page will just download the first type that it supports. I am wondering how preloading affect this ...
Does it
- preload all items that are specified irrespective of the
video controls
- preload the first item with a particular name prefix it can handle - ie if both files are named "sintel-short" it just downloads the first one?
- preload all items that it can handle irrespective of name
- preload those files can't handle/display
Ultimately I want to confirm if this statement after the example code makes sense:
So in this case, browsers that support MP4s will preload and use the MP4, making the video player hopefully smoother/more responsive for users. Browsers that don't support MP4 can still load the WebM version, but don't get the advantages of preloading. This shows how preloading content can be combined with the philosophy of progressive enhancement.
Assignee | ||
Comment 36•3 years ago
|
||
I think that statement is wrong. If the browser supports both webm and mp4 it would preload both, see the code here.
I think the <link rel="preload" type="video/webm">
should be removed from the example, then the example and the text both would be correct (you'd only preload the mp4 if you support it, which would be the primary source of the video, but if the browser doesn't support it you still get the webm).
Comment 37•3 years ago
|
||
Don't know what's wrong, but this code below doesn't work in version 85 (the style is ignored completely). Was it supposed to be fixed?
<link rel="preload" href="style.css" as="style">
Assignee | ||
Comment 38•3 years ago
|
||
That just preloads the style, but the style isn't used anywhere. You need to add a <link rel="stylesheet" href="style.css">
there as well, or onload="this.onload = null; this.rel = 'stylesheet'"
to the <link rel="preload">
.
Comment 39•3 years ago
|
||
Right.. it's going to take many questions from users why the code I posted doesn't work, but your answer helped, thank you.
Comment 40•3 years ago
|
||
BTW - I tried and this code below seems to work (ie. it loads the style), but doesn't actually preloads the style?
<link rel="preload stylesheet" href="style.css" as="style">
Assignee | ||
Comment 41•3 years ago
|
||
That seems like it should work, why do you say it's not getting preloaded? We do get to HTMLLinkElement::StartPreload
on that test-case, fwiw.
Note that if you're not testing from an http/https site it won't work on 85 because of bug 1685830.
Comment 42•3 years ago
|
||
Yes, it works, just wanted to make sure it's going to work in the future too (I like it because it's a short version). Thank you.
Assignee | ||
Comment 43•3 years ago
|
||
Yeah, that is indeed nicer. Note that there's some weirdness since that should get two load events (one from the stylesheet, one from the preload), which might be a bit odd. But that is also true of the <link rel=preload as=style onload=...>
approach so... Plus yours works without JS which is nicer.
Comment 44•3 years ago
|
||
Forgive me if I missed it but is this fix going to trickle back to esr firefox see:
https://github.com/webcompat/web-bugs/issues/67273
I've also experienced other random problems which, after reading through this bug were most likely caused by "network.preload" being set "False"
Assignee | ||
Comment 45•3 years ago
|
||
I'd say it's unlikely for a patch enabling features like this to be backported to esr... Though it's not really my call I guess, and if the problems it causes are really severe it might make sense... Ryan / Julien, do you have opinions?
Comment 46•3 years ago
|
||
Feature backports are out of scope for ESR releases, yes.
Description
•