Remove webfont.js as render-blocking resource - lighthouse

636 views Asked by At

I'm currently trying to optimize my site and load font family asynchronously

At first it was an issue with material icons like in image below

enter image description here

After getting rid of this issue by using webfontloader in index.html I now have this error, which hasn't been as easy to get rid of

enter image description here

To try and solve it I changed the CDN link <script src="https://ajax.googleapis.com/ajax/libs/webfont/1.5.18/webfont.js"></script> to webfont.js to using npm i webfontloader and loading it locally, but the issue is still there. How can I get webfont.js to not be render-blocking?

index.html

<!doctype html>
<html lang="en">

<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta charset="utf-8">
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta charset="UTF-8">
  <title>My App</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="assets/logo.ico">


  <script src="../node_modules/webfontloader/src/core/webfont.js"></script>
  <script>
    WebFont.load({
      google: {
        families: ['Material+Icons']
      }
    });
  </script>



</head>

<body>
  <app-root>

  </app-root>
</body>


</html>

0

There are 0 answers