question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Preload key requests

See original GitHub issue

Light House is suggesting that I preload key requests, specifically the two google fonts that I’m using in my React app. Currently I’m just importing them like this: @import url('https://fonts.googleapis.com/css?family=Open+Sans|Roboto:700') I’ve been looking for an example of how to do this but, everything I’ve tried doesn’t seem to work. Any suggestions would be much appreciated.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
wildpowcommented, Jun 12, 2018

Well I got it to work with this bit of code:

<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
<link rel="preload" as="style" href="https://fonts.googleapis.com/css?family=Open+Sans|Roboto:700" crossorigin>
<link href="https://fonts.googleapis.com/css?family=Open+Sans|Roboto:700" rel="stylesheet" crossorigin>

Without adding the crossorgin property to the second link tag I get a render blocking stylesheet warning from LightHouse but, this whole endeavor to preload font fonts per Light House’s suggestion as upped my first meaningful paint to 3620ms from 2650ms and lower my lighthouse score from 88 to 79. Not sure if the preload suggestion is general and doesn’t work with the way Google serves their fonts or if I’m still doing something wrong. Just frustrating to follow these optimization guide-lines and end up with a slower product.

1reaction
patrickhulcecommented, Aug 27, 2018

Sorry I missed this reply @wildpow thanks for sending over the reports!

This is a very interesting case, the successful preloading improves First Contentful Paint as expected, but First Meaningful Paint gets worse because of a quirk in its implementation (the same quirks that were the rationale for decreasing its priority/weight in v3 and promotion of FCP in its place). The regression in the other metrics seems to be unrelated to the preload change and looks like natural variance. If we had been tracking FCP in v2, the incremental improvement from preloading would have been reflected there.

Thanks for bringing this up and sorry for the confusion! Hopefully these cases are addressed in v3 with the new prioritization/metrics 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Preload key requests - Chrome Developers
Declare preload links in your HTML to instruct the browser to download key resources as soon as possible. ... With preload links, styles.css...
Read more >
Lighthouse: Preload key requests - GTmetrix
Using <link rel="preload"> can help you prioritize important requests, resulting in a faster page load. This is because key resources may sometimes be ......
Read more >
How to Preload Key Requests in WordPress (PageSpeed Item)
Preloading key requests instructs browsers to download your critical resources as soon as possible. In WordPress, preload is most commonly ...
Read more >
Preload key requests WP Rocket | How-to Guide - Bobcares
Preloading key requests includes informing the browser to download the critical assets by prioritizing them. In other words, it ensures relevant ...
Read more >
How to fix PageSpeed Insights' "preload key request" problem ...
The key preload request problem is an outcome of overusing this method. On checking your site with PageSpeed Insights, you might face some ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found