-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggest <link rel="preload"> #931
Comments
Kk |
Going to bucket this one under the new loading audits milestone if that's cool? :) Feel free to riff on these. Description: Critical resources that are discovered late can be preloaded to fetch them earlier. |
I guess critical-ish assets are assets that are not preloaded and are not requested by the document itself? So all critical assets that are not picked up by the preload scanner? Should we consider H2 push as well? If so can devtools detect that it's h2 push? |
yah this seems like a good place to start.
No. h2 push requires a bunch of conversation that we don't want to mix up on this one. :) |
I think we should start more conservatively. Async JS files that are preloaded will introduce network contention against actual critical JS files. There is probably some opportunity in here, but it's gonna be too difficult to generalize and be correct. Let's start with: Only consider critical requests. Only requests of CRC depth = 2. This will deliver webfonts pretty often. It will also include scripts that other scripts request (like on my site). Seems good. |
@paulirish so this would be ok? I need to write unit tests and smoke tests and than it's good to go 😄 |
|
Focusing on at least CRC depth =2 sounds good. Are we initially limiting the preload audit to scripts? In case useful here are (ranked) how preload is used in the wild today:
Thus is based on the last look I had through HA. For PWAs, preloading JS is a pattern becoming more common and I could see value in starting there initially. |
There is a lot of nuance when using link rel preload, as it is trivial to preload "incorrectly" thus causing double requests, and therefore resulting in worse performance. I am wondering if link rel preload is mature enough to point people down this path at the current date. |
I doesn't have to be scripts only. I've fixed the audit now on paulirish.com it has nothing to preload as the youtube video is a preload |
I somewhat agree with @samccone here. This and preconnect audit is the first area where following our performance opportunity recommendations may actually hurt another aspect of performance. Is there an even more limited subset than depth 2 that'd be bulletproof? CRC sweeps all the way down to Medium priority here and is a rather wide net. |
My proposal:
And because CRC depth=2, we'd only be recommending preload for the above included resourceTypes if their request was initiated by way of a primary script/stylesheet. (but not the HTML). That feels fairly conservative to me already.
|
That all sounds good. I guess my concern is muddying the "Opportunities" section as just pure wins when the benefit is missing/negative for some situations (i.e. reporting that preloading a css file for hidden UI would save you X seconds on your load feels wrong). How do folks feel about surfacing this info in Diagnostics instead? IMO, this changes the tone from "Loading these late was bad. Move them earlier for better performance!" to "These were loaded late and looked important. Do you want to preload them?" |
Aye. It's reasonable for this to start in Diagnostics rather than Opportunties. Generally, we won't be able to have the certainty to confirm a preload/preconnect is definitely a win, so it seems good to offer our knowledge to the dev and let them make a call. (Again, communicating the scoring is based on the metrics only). There are some cases where preload is a sure win. (If a site loads gpt.js then pubads_impl.js will definitely be loaded.) But we'll probably have to hardcode those cases. |
This is a pretty reasonable list of includes imo.
I'm pretty favorable towards including preload recommendations in Diagnostics to start off with. Reading back through the concerns @patrickhulce and @samccone had, I agree there's definitely potential for us to make a suggestion that isn't guaranteed to actually improve perf. Presenting preload as an optional addition you might want to apply vs something you 100% should apply makes sense as we're unable to determine that it would definitely improve things every time. |
🤔 thought the preload didn't have many drawbacks 😛 I'll start implement what @paulirish suggested. |
Key for this one and the preconnect:
|
I get the message "Consider using to prioritize fetching resources that are currently requested later in page load." for a resource that is already using this. |
@CodeZeno please file a separate issue with repro steps if you believe you've found a bug you'd like addressed. |
critical-ish assets which are requested later by the page
@samccone interested?
The text was updated successfully, but these errors were encountered: