Check 06.17 · Performance and Core Web Vitals

Preload only critical resources

Keep preload, preconnect and Early Hints for critical resources discovered late: tags, Link headers and settings by server, CDN, CMS and framework.

Priority
Important
Difficulty
Intermediate
Estimated time
1 to 2 h
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

<link rel="preload"> tells the browser to download a resource right away, with high priority, without waiting to discover it on its own. It is useful for a handful of critical, hidden resources: the main text font, a hero image declared in the CSS, a file loaded indirectly. Applied to everything, preloading has the opposite effect: the truly critical resources end up competing with all the others. Expected result: a few justified preloads, all of them used, and no warning in the console.

Why it matters

As soon as the HTML arrives, the browser scans ahead through it to start downloading the resources it finds there: stylesheets, scripts, images with a src attribute. This mechanism does not see what is hidden further away:

  • fonts, referenced in the CSS and requested only when some visible text needs them;
  • background images declared in CSS;
  • files loaded through @import or injected by JavaScript.

These resources start late. If one of them determines the main display, preloading saves the whole discovery delay.

But bandwidth and connections are shared. Each extra preload takes its share, at the expense of the CSS, the hero image or the script that makes the page interactive. A resource that is preloaded and never used is pure waste, which Chrome flags in the console.

Preloading is only one of the available resource hints:

Hint Effect Use for
preload downloads now, with high priority a critical resource of the page, discovered late
modulepreload the same for a JavaScript module and its dependencies modules needed for rendering
preconnect opens the connection (DNS, TCP, TLS) to a domain one or two critical third-party domains
dns-prefetch only resolves DNS secondary third-party domains
prefetch downloads with low priority for a future navigation the likely next page
fetchpriority attribute adjusts the priority of a resource already visible in the HTML hero image, secondary script

Early Hints (HTTP 103 response) let you send these hints before the server has even finished generating the page.

What it improves

  • LCP (Largest Contentful Paint, the display of the largest visible element): a real gain when the main element depends on a resource discovered late.
  • Text stability A preloaded font arrives before the first render, which limits font swapping and the associated CLS (Cumulative Layout Shift).
  • Useful throughput Removing unnecessary preloads gives priority back to critical resources. This is often where the gain lies.
  • Rankings Indirect effect, through Core Web Vitals.

How to check

List the hints present in the HTML and in the headers:

curl -s https://example.com/ | grep -o -i -E '<link[^>]+rel="?(preload|modulepreload|preconnect|dns-prefetch|prefetch)"?[^>]*>'
curl -s -o /dev/null -D - https://example.com/ | grep -i "^link:"

Then, in Chrome:

  • Console: reload the page and wait a few seconds. A warning saying that a resource was preloaded but not used points to a preload to remove or fix.
  • Network tab: show the “Priority” column. Preloaded resources should appear only once. Two lines for the same file indicate an inconsistent as, type or crossorigin attribute.
  • Early Hints: the first response shown by curl -s -o /dev/null -D - https://example.com/ is HTTP/2 103 when they are active.

Compliant result: a few preloads at most per template, each matching a resource used in the first screen.

How to implement

Before you start

Only preload a resource if it meets all three conditions: it is needed for the first screen, the browser discovers it late, and you have observed this delay in the network waterfall.

Main text font:

<link rel="preload" href="/fonts/inter-latin.woff2" as="font" type="font/woff2" crossorigin>

Hero image declared in CSS or inserted by JavaScript, with responsive variants:

<link rel="preload" as="image" href="/images/hero-1200.webp"
      imagesrcset="/images/hero-600.webp 600w, /images/hero-1200.webp 1200w, /images/hero-2000.webp 2000w"
      imagesizes="100vw" fetchpriority="high">

Third-party domain essential to the first screen:

<link rel="preconnect" href="https://cdn.example.net">

The same thing as an HTTP header, useful when you cannot modify the template and required for Early Hints:

Link: </fonts/inter-latin.woff2>; rel=preload; as=font; type="font/woff2"; crossorigin

Good to know: when the hero image is an <img> tag present in the HTML, the browser already discovers it. Add fetchpriority="high" to it rather than a preload: see optimize the LCP image without lazy loading (opens in a new tab).

Apache

Versions Apache 2.4 (H2EarlyHints since 2.4.24).

Add the header to HTML responses only, in the virtual host or the .htaccess file:

<IfModule mod_headers.c>
    Header add Link "</fonts/inter-latin.woff2>; rel=preload; as=font; type=\"font/woff2\"; crossorigin" "expr=%{CONTENT_TYPE} =~ m#^text/html#"
</IfModule>

Reload with sudo apachectl configtest && sudo systemctl reload apache2. With mod_http2, the H2EarlyHints on directive allows 103 responses to be sent; refer to the module's documentation for the resources announced.

Nginx

Versions Nginx 1.25.1 and later (early_hints directive: 1.29.0 and later).

In the http context, set the value according to the response type, then add the header in the server block:

map $sent_http_content_type $preload_link {
    default "";
    ~^text/html '</fonts/inter-latin.woff2>; rel=preload; as=font; type="font/woff2"; crossorigin';
}

server {
    listen 443 ssl;
    http2 on;
    server_name example.com;

    add_header Link $preload_link;
}

Nginx does not send the header when the variable is empty. Since version 1.29.0, the early_hints directive passes to the client the 103 responses sent by the application behind proxy_pass. Test and reload: sudo nginx -t && sudo systemctl reload nginx.

Cloudflare

Versions Cloudflare dashboard, all plans, November 2026.

Enable Early Hints in Speed > Settings > Content Optimization. The feature is available on all plans. Cloudflare stores the preload and preconnect Link headers returned by your origin, then sends them in a 103 response on subsequent visits, while the origin prepares the page.

Points to know:

  • Cloudflare reads HTTP Link headers, not the <link> tags in the HTML. Without a header at the origin, nothing is sent.
  • Early Hints only work over HTTP/2 and HTTP/3, and only some browsers make use of them.
  • The announced resources are requested by every visitor: only include what is common to all the pages concerned.

Vercel

Versions Vercel, all plans, vercel.json file, November 2026.

In vercel.json:

{
  "headers": [
    {
      "source": "/",
      "headers": [
        {
          "key": "Link",
          "value": "</fonts/inter-latin.woff2>; rel=preload; as=font; type=\"font/woff2\"; crossorigin"
        }
      ]
    }
  ]
}

Adapt source to the paths concerned (/(.*) for all pages).

Netlify

Versions Netlify, all plans, _headers file, November 2026.

In the _headers file of the publish directory (replace / with /* for all pages):

/
  Link: </fonts/inter-latin.woff2>; rel=preload; as=font; type="font/woff2"; crossorigin

WordPress

Versions WordPress 6.6 and later (up to 7.1).

Since WordPress 6.1, the wp_preload_resources filter adds preloads to the <head>:

add_filter('wp_preload_resources', function (array $resources): array {
    $resources[] = [
        'href' => get_theme_file_uri('assets/fonts/inter-latin.woff2'),
        'as' => 'font',
        'type' => 'font/woff2',
        'crossorigin' => 'anonymous',
    ];

    if (is_front_page()) {
        $resources[] = [
            'href' => get_theme_file_uri('assets/images/hero-1200.webp'),
            'as' => 'image',
            'fetchpriority' => 'high',
        ];
    }

    return $resources;
});

The fetchpriority key has been supported since WordPress 6.6. For a preconnect:

add_filter('wp_resource_hints', function (array $urls, string $relationType): array {
    if ($relationType !== 'preconnect') {
        return $urls;
    }

    $urls[] = ['href' => 'https://cdn.example.net'];

    return $urls;
}, 10, 2);

Also take the reverse inventory: themes, page builders and caching plugins often add their own preloads (icon fonts, every weight of a family). Search for rel="preload" in the page source and disable, in their settings, those that do not serve the first screen.

Shopify

Versions Online Store 2.0 themes (Liquid), November 2026.

The preload_tag filter generates the tag and the matching Link header, for a theme file passed through asset_url:

{{ 'critical.js' | asset_url | preload_tag: as: 'script' }}

For a font chosen in the theme settings, write the tag yourself:

<link rel="preload" as="font" href="{{ settings.type_body_font | font_url }}" type="font/woff2" crossorigin>

The image_tag filter accepts a preload: true parameter, which sends a Link header for the image. Keep it for the hero image of the first screen: Shopify recommends using it sparingly.

PrestaShop

Versions PrestaShop 8 and 9.

Add the tag in themes/votre-theme/templates/_partials/head.tpl, preferably in a child theme:

<link rel="preload" href="{$urls.theme_assets}fonts/inter-latin.woff2" as="font" type="font/woff2" crossorigin>

Clear the Smarty cache in Advanced Parameters > Performance.

Magento

Versions Magento Open Source and Adobe Commerce 2.4 (up to 2.4.9).

The layout accepts a tag dedicated to fonts, which produces a preload. In your theme's Magento_Theme/layout/default_head_blocks.xml:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <font src="fonts/inter/inter-latin.woff2"/>
    </head>
</page>

The Luma theme preloads several Open Sans weights this way: remove those your theme does not use with <remove src="fonts/opensans/light/opensans-300.woff2"/>. Clear the cache (bin/magento cache:flush) and check the HTML output.

Drupal

Versions Drupal 10 and 11.

In montheme.theme. The second element of the array, set to true, also adds the HTTP Link header:

function montheme_page_attachments_alter(array &$attachments): void
{
    $attachments['#attached']['html_head_link'][] = [
        [
            'rel' => 'preload',
            'href' => '/themes/custom/montheme/fonts/inter-latin.woff2',
            'as' => 'font',
            'type' => 'font/woff2',
            'crossorigin' => 'anonymous',
        ],
        true,
    ];
}

Wix

Versions Wix (Wix Editor and Wix Studio) and Squarespace, November 2026.

No setting: the platform manages resource hints itself. The same applies to Squarespace.

Webflow

Versions Webflow, paid site plans (custom code), November 2026.

You can add a <link rel="preload"> tag in Site settings > Custom code > Head code, but only for a resource whose URL is stable. Files managed by Webflow change address with every publication: do not preload them by hand.

Laravel

Versions Laravel 10 to 13.

Vite itself adds the modulepreload hints for the code chunks each entry point needs. To also send them as Link headers (and make them usable by a CDN's Early Hints), register the AddLinkHeadersForPreloadedAssets middleware provided by the framework in the web group. Only the place where you register it changes between versions.

Other preloads are written in the Blade template: see the font example in optimize fonts (opens in a new tab). Since Laravel 13, the Vite plugin's fonts option can also generate preloads for self-hosted fonts (the preload option), inserted by the @fonts Blade directive.

Laravel 11 to 13

In bootstrap/app.php:

use Illuminate\Foundation\Configuration\Middleware;
use Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets;

->withMiddleware(function (Middleware $middleware): void {
    $middleware->web(append: [
        AddLinkHeadersForPreloadedAssets::class,
    ]);
})

Laravel 10

In app/Http/Kernel.php, add the class at the end of the web group of the $middlewareGroups property:

protected $middlewareGroups = [
    'web' => [
        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \Illuminate\Session\Middleware\StartSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        \App\Http\Middleware\VerifyCsrfToken::class,
        \Illuminate\Routing\Middleware\SubstituteBindings::class,
        \Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets::class,
    ],
];

Symfony

Versions Symfony 6.4 and later (up to 8.1).

The WebLink component (composer require symfony/web-link) adds the Link header from Twig:

<link rel="preload" href="{{ preload(asset('fonts/inter-latin.woff2'), {as: 'font', type: 'font/woff2', crossorigin: 'anonymous'}) }}" as="font" type="font/woff2" crossorigin>
<link rel="preconnect" href="{{ preconnect('https://cdn.example.net') }}">

With a server that supports 103 responses, such as FrankenPHP or RoadRunner, a controller can send Early Hints before building the page:

public function index(): Response
{
    $response = $this->sendEarlyHints([
        (new Link(href: '/fonts/inter-latin.woff2'))
            ->withAttribute('as', 'font')
            ->withAttribute('crossorigin', 'anonymous'),
    ]);

    return $this->render('home/index.html.twig', response: $response);
}

Next.js

Versions Next.js 15 and 16 (App Router).

The framework already preloads its stylesheets, the fonts declared with next/font and the next/image images marked preload (a prop introduced in Next.js 16, which replaces the deprecated priority; on Next.js 15, use priority). For a one-off need, use React's functions:

import { preconnect, preload } from 'react-dom';

export default function Page() {
  preconnect('https://cdn.example.net');
  preload('/images/hero-1200.webp', { as: 'image', fetchPriority: 'high' });

  return <main className="hero">Content</main>;
}

The Link component also prefetches the routes visible on screen: this is navigation prefetch, to be disabled (prefetch={false}) on very long lists of links.

Nuxt

Versions Nuxt 3 and 4, Nuxt Image module for NuxtImg.

Nuxt adds the necessary modulepreload hints. For the rest:

useHead({
  link: [
    {
      rel: 'preload',
      href: '/fonts/inter-latin.woff2',
      as: 'font',
      type: 'font/woff2',
      crossorigin: 'anonymous',
    },
  ],
});

The NuxtImg component accepts a preload prop for the hero image; pass it an object (:preload="{ fetchPriority: 'high' }") to prioritize it as well.

Astro

Versions Astro 6 and 7.

Write the tag in the layout's <head>. For a font managed by the fonts API (stable since Astro 6), the preload prop of the Font component takes care of it. For an image processed by Astro, the priority prop of the Image component is enough in most cases: the image is in the HTML, so it is already discovered.

Common mistakes

  • Preloading to “speed things up” without looking at the waterfall: a resource already discovered early (the main stylesheet in the <head>) gains nothing.
  • Forgetting the as attribute: the resource is downloaded with the wrong priority, then a second time.
  • Forgetting crossorigin on a font: double download, even on your own domain.
  • Preloading a URL that no longer matches: a versioned file name that changed with the last deployment, another format or another size than the one actually used.
  • Preloading both the desktop and the mobile image without imagesrcset or a media attribute: every visitor downloads both.
  • Confusing preload and prefetch: prefetch has low priority and targets the next page.
  • Adding too many preconnect hints: every connection opened and left unused costs CPU and network. Keep them for one or two domains.
  • Announcing page-specific resources in Early Hints: the 103 response stored by the CDN is replayed on visits where they are not needed.

Frequently asked questions

What is the difference between preload, prefetch and preconnect?

Preload immediately downloads, with high priority, a resource needed by the current page. Prefetch downloads, with low priority, a resource useful for a likely future navigation, such as the next page. Preconnect only opens the connection, meaning DNS resolution, TCP and TLS, to a domain the page will need: keep it for one or two critical third-party domains.

Why does Chrome report a resource as preloaded but not used?

This console warning means that a file was preloaded without the page using it shortly afterwards: bandwidth taken away from critical resources. The usual causes are a URL that no longer matches, such as a versioned name changed at deployment, an inconsistent as, type or crossorigin attribute, or a resource that is not needed for the first screen. Fix or remove that preload.

What are Early Hints?

Early Hints are an HTTP 103 response sent before the page itself: it tells the browser which resources to preload and which domains to preconnect to while the server is still generating the HTML. Cloudflare offers them on all plans, based on your origin's Link headers. They only work over HTTP/2 and HTTP/3, and only some browsers make use of them.

Updated on

Topic checklist (PDF)

And now?

In the “Performance and Core Web Vitals” topic

  1. Analyze PageSpeed Insights and Lighthouse
  2. Analyze real-user CrUX data
  3. Target LCP ≤ 2.5 s at the 75th percentile
  4. Target INP ≤ 200 ms at the 75th percentile
  5. Target CLS ≤ 0.1 at the 75th percentile
  6. Target TTFB ≤ 800 ms as a benchmark
  7. Optimize hosting and CDN
  8. Enable Brotli/Gzip
  9. Configure browser and server caching
  10. Minify CSS and JavaScript
  11. Remove unused CSS/JS
  12. Reduce render-blocking resources
  13. Defer non-essential scripts
  14. Limit third-party scripts
  15. Optimize database queries
  16. Optimize fonts (WOFF2, font-display)
  17. Preload only critical resources
  18. Optimize the LCP image without lazy loading
  19. Lazy-load offscreen content
  20. Reserve space for media and ads
  21. Reduce DOM complexity
  22. Test before and after cookie consent
  23. Test on a slow mobile connection
  24. Set a performance budget
  25. Preload likely navigations with Speculation Rules
  26. Make pages eligible for the back/forward cache (bfcache)
  27. Diagnose INP with Long Animation Frames (LoAF)