Consider using `<link rel=preload>` to prioritize fetching resources that are currently requested later in page load.

Created on 2 December 2020, about 4 years ago
Updated 25 February 2023, almost 2 years ago

I'm checking my site with PageSpeed Insights Tool and i'm getting this message:

>Preload key requests
Consider using `
` to prioritize fetching resources that are currently requested later in page load.

Could someone help me to know how implement this recommendation on my Drupal 8 site.

Thanks.

🌱 Plan
Status

Active

Version

4.0

Component

Fonts

Created by

πŸ‡²πŸ‡½Mexico mpena

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΎUruguay ruby232 Montevideo

    I have the same problem, this is happening because the regex in the DeferCss class does not match the urls of sources.googleapis.com.
    I gave you a custom solution

    In my theme.libraries.ym i add:
    //fonts.googleapis.com/css?family=Montserrat:400,500,600,700|Work+Sans:400,500,600,700: { type: external, attributes: { as: style, onload: "this.rel='stylesheet'" } }

    And in mi theme.module i add:

    /**
     * Implements hook_page_attachments_alter().
     *
     */
    function theme_page_attachments_alter(array &$attachments) {
      $html = '<noscript><link rel="stylesheet" media="all" href="//fonts.googleapis.com/css?family=Montserrat:400,500,600,700|Work+Sans:400,500,600,700" /></noscript>';
      $attachments['#attached']["html_head"][] = [
        [
          '#type' => 'inline_template',
          '#template' => $html,
        ]
      ];
    }

    I base myself on the operation of the module html_head β†’ .

Production build 0.71.5 2024