--- url: "https://web.dev/articles/fetch-priority" titulek: "Optimize resource loading with the Fetch Priority API | Articles | web.dev" h1: "Optimize resource loading with the Fetch Priority API Stay organized with collections Save and categorize content based on your preferences." popis: "The Fetch Priority API indicates the relative priority of resources to the browser. It can enable optimal loading and improve Core Web Vitals." jazyk: "en" kanonicka: "https://web.dev/articles/fetch-priority" drobecky: ["Articles", "Optimize resource loading with the Fetch Priority API"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 23:11:11" znaku: 19633 slov: 2900 kodovani: "iso-8859-2" sha256: "f65d38c1068d24fbb060914d526bf50d104384e8e7528c462be73759d4c28076" --- Optimize resource loading with the Fetch Priority API Stay organized with collections Save and categorize content based on your preferences. The Fetch Priority API indicates the relative priority of resources to the browser. It can enable optimal loading and improve Core Web Vitals. Addy Osmani Leena Sohoni Patrick Meenan Barry Pollard Browser Support 102 102 132 17.2 [Source](https://developer.mozilla.org/docs/Web/API/HTMLImageElement/fetchPriority) When a browser parses a web page and begins to discover and download resources such as images, scripts, or CSS, it assigns them a fetch `priority` so it can download them in an optimal order. A resource's priority usually depends on what it is and where it is in the document. For example, in-viewport images might have a `High` priority, and the priority for early loaded, render-blocking CSS using ``s in the `` might be `Very High`. Browsers are pretty good at assigning priorities that work well but may not be optimal in all cases. This page discusses the Fetch Priority API and the `fetchpriority` HTML attribute, which lets you hint at the relative priority of a resource (`high` or `low`). Fetch Priority can help optimize the Core Web Vitals. Summary **A few key areas where Fetch Priority can help:** Boosting the priority of the LCP image by specifying `fetchpriority="high"` on the image element, causing LCP to happen sooner. Increasing the priority of `async` scripts, using better semantics than the current most common hack (inserting a `` for the `async` script). Decreasing the priority of late-body scripts to allow for better sequencing with images. Fetch Priority improving Largest Contentful Paint from 2.6 s to 1.9 s in a test of Google Flights. Historically, developers have had limited influence over resource priority using [preload](https://developer.chrome.com/docs/lighthouse/performance/uses-rel-preload) and [preconnect](https://developer.chrome.com/docs/lighthouse/performance/uses-rel-preconnect). Preload lets you tell the browser about critical resources you want to load early before the browser would naturally discover them. This is especially useful for resources that are harder to discover, such as fonts included in stylesheets, background images, or resources loaded from a script. Preconnect helps warm up connections to cross-origin servers and can help improve metrics like [Time to first byte](/articles/ttfb). It's useful when you know an origin but not necessarily the exact URL of a resource that will be needed. Fetch Priority complements these [Resource Hints](https://www.w3.org/TR/resource-hints/). It's a markup-based signal available through the `fetchpriority` attribute that developers can use to indicate the relative priority of a particular resource. You can also use these hints through JavaScript and the [Fetch API](/articles/introduction-to-fetch) with the `priority` property to influence the priority of resource fetches made for data. Fetch Priority can also complement preload. Take a Largest Contentful Paint image, which, when preloaded, will still get a low priority. If it is pushed back by other early low-priority resources, using Fetch Priority can help how soon the image gets loaded. Resource priority The resource download sequence depends on the browser's assigned priority for every resource on the page. The factors that can affect priority computation logic include the following: The type of resource, such as CSS, fonts, scripts, images, and third-party resources. The location or order the document references resources in. Whether the [`async` or `defer`](/articles/efficiently-load-third-party-javascript#use_async_or_defer) attributes are used on scripts. The following table shows how Chrome prioritizes and sequences most resources: Load in layout-blocking phase Load one-at-a-time in layout-blocking phase **Blink Priority** **VeryHigh** **High** **Medium** **Low** **VeryLow** **DevTools Priority** **Highest** **High** **Medium** **Low** **Lowest** Main resource CSS (early**) CSS (late**) CSS (media mismatch***) Script (early** or not from preload scanner) Script (late**) Script (async) Font Font (rel=preload) Import Image (in viewport) Image (first 5 images > 10,000px2) Image Media (video/audio) Prefetch XSL XHR (sync) XHR/fetch* (async) The browser downloads resources with the same computed priority in the order they're discovered. You can check the priority assigned to different resources when loading a page under the Chrome Dev Tools **Network** tab. (Make sure you include the **priority** column by right-clicking the table headings and ticking that). Priority for resource `type = "font"` on BBC news detail page Priority for resource `type = "script"` on BBC news detail page. When priorities change, you can see both the initial and final priority in the **Big request rows** setting or in a tooltip. Priority changes in DevTools. When might you need Fetch Priority? Now that you understand the browser's prioritization logic, you can tweak your page's download order to optimize its performance and [Core Web Vitals](/articles/vitals). Here are some examples of things you can change to influence the priority of resource downloads: Place resource tags like `` Effects of browser priority and `fetchpriority` You can apply the `fetchpriority` attribute to different resources as shown in the following table to increase or reduce their computed priority. `fetchpriority="auto"` (◉) in each row marks the default priority for that type of resource. (also available [as a Google Doc](https://docs.google.com/document/d/1bCDuq9H1ih9iNjgzyAL0gpwNFiEP4TZS-YLRp_RuMlc/edit)). Load in layout-blocking phase Load one at a time in layout-blocking phase **Blink Priority** **VeryHigh** **High** **Medium** **Low** **VeryLow** **DevTools Priority** **Highest** **High** **Medium** **Low** **Lowest** Main Resource ◉ CSS (early**) ⬆◉ ⬇ CSS (late**) ⬆ ◉ ⬇ CSS (media mismatch***) ⬆*** ◉⬇ Script (early** or not from preload scanner) ⬆◉ ⬇ Script (late**) ⬆ ◉ ⬇ Script (async/defer) ⬆ ◉⬇ Font ◉ Font (rel=preload) ⬆◉ ⬇ Import ◉ Image (in viewport - after layout) ⬆◉ ⬇ Image (first 5 images > 10,000px2) ⬆ ◉ ⬇ Image ⬆ ◉⬇ Media (video/audio) ◉ XHR (sync) - deprecated ◉ XHR/fetch* (async) ⬆◉ ⬇ Prefetch ◉ XSL ◉ `fetchpriority` sets *relative priority*, meaning it raises or lowers the default priority by an appropriate amount, rather instead of explicitly setting the priority to `High` or `Low`. This often results in `High` or `Low` priority, but not always. For example, critical CSS with `fetchpriority="high"` retains the "Very High"/"Highest" priority, and using `fetchpriority="low"` on these elements retains the "High" priority. Neither of these cases involve explicitly setting priority to `High` or `Low`. Use cases Use the `fetchpriority` attribute when you want to give the browser an extra hint about what priority to fetch a resource with. Increase the priority of the LCP image You can specify `fetchpriority="high"` to boost the priority of the LCP or other critical images. `` The following comparison shows the Google Flights page with an LCP background image loaded with and without Fetch Priority. With the priority set to high, the [LCP improved from 2.6s to 1.9s](https://www.webpagetest.org/video/compare.php?tests=211006_AiDcG3_40871b05d6040112a05be4524565cf5d%2C211006_BiDcHR_bebed947f1b6607f2d97e8a899fdc36b&thumbSize=200&ival=100&end=visual). An experiment conducted using Cloudflare workers to rewrite the Google Flights page using Fetch Priority. Lower the priority of above-the-fold images Use `fetchpriority="low"` to lower the priority of above-the-fold images that aren't immediately important, for example offscreen images in an image carousel. `` While images 2-4 will be outside of the viewport, they may be considered "close enough" to boost them to `high` and also load even if a `load=lazy` attribute is added. Therefore `fetchpriority="low"` is the correct solution for this. In an earlier experiment with the [Oodle](https://github.com/google/oodle-demo) app, we used this to lower the priority of images that don't appear on load. It decreased page load time by 2 seconds. Using high priority for only the first carousel image lets the page load faster. Lower the priority of preloaded resources To stop preloaded resources from competing with other critical resources, you can reduce their priority. Use this technique with images, scripts, and CSS. ` ` Reprioritize scripts Scripts your page needs to be interactive should be load quickly, but shouldn't block other, more critical, render-blocking resources. You can mark these as `async` with high priority. `` You can't mark a script as `async` if it relies on specific DOM states. However, if they run later on the page, you can load them with lower priority: `` This will still block the parser when it reaches this script, but will allow content before this to be prioritised. An alternative, if the completed DOM is needed, is to use the `defer` attribute (which runs, in order, after [DOMContentLoaded](https://developer.mozilla.org/docs/Web/API/Document/DOMContentLoaded_event)), or even `async` at the bottom of the page. Lower the priority for non-critical data fetches The browser executes `fetch` with a high priority. If you have multiple fetches that might fire simultaneously, you can use the high default priority for the more important data fetches and lower the priority of less critical data. `// Important validation data (high by default) let authenticate = await fetch('/user'); // Less important content data (suggested low) let suggestedContent = await fetch('/content/suggested', {priority: 'low'});` Fetch Priority implementation notes Fetch Priority can improve performance in specific use cases but there are some things to be aware of when using Fetch Priority: The `fetchpriority` attribute is a hint, not a directive. The browser tries to respect the developer's preference, but it can also apply its resource priority preferences for resource priority to resolve conflicts. Don't confuse Fetch Priority with preloading: Preload is a mandatory fetch, not a hint. Preload lets the browser discover a resource early, but it still fetches the resource with the default priority. Conversely, Fetch Priority doesn't help with discoverability, but it does let you increase or decrease the fetch priority. It's often easier to observe and measure the effects of a preload than the effects of a priority change. Fetch Priority can complement preloads by increasing the granularity of prioritization. If you've already specified a preload as one of the first items in the `` for an LCP image, then a `high` Fetch Priority might not improve LCP significantly. However, if the preload happens after other resources load, a `high` Fetch Priority can improve LCP more. If a critical image is a CSS background image, preload it with `fetchpriority = "high"`. Load time improvements from prioritization are more relevant in environments where more resources compete for the available network bandwidth. This is common for HTTP/1.x connections where parallel downloads aren't possible, or on low bandwidth HTTP/2 or HTTP/3 connections. In these cases, prioritization can help resolve bottlenecks. CDNs don't [implement HTTP/2 prioritization](https://github.com/andydavies/http2-prioritization-issues#cdns--cloud-hosting-services) uniformly, and similarly for HTTP/3. Even if the browser communicates the priority from Fetch Priority, the CDN might not reprioritize resources in the specified order. This makes testing Fetch Priority difficult. The priorities are applied both internally within the browser and with protocols that support prioritization (HTTP/2 and HTTP/3). It's still worth using Fetch Priority just for the internal browser prioritization independent of CDN or origin support, because priorities often change when the browser requests resources. For example, low-priority resources like images are often held back from being requested while the browser processes critical `` items. You might not be able to introduce Fetch Priority as a best practice in your initial design. Later in your development cycle, you can the priorities being assigned to different resources on the page, and if they don't match your expectations, you can introduce Fetch Priority for further optimization. Developers should use preload for its [intended purpose](https://www.smashingmagazine.com/2016/02/preload-what-is-it-good-for/#loading-of-late-discovered-resources)—to preload resources not detected by the parser (fonts, imports, background LCP images). The placement of the `preload` hint will affect when the resource is preloaded. Fetch priority is about how the resource should be fetched when it is fetched. Tips for using preloads Keep the following in mind when using preloads: Including a preload in HTTP headers puts it before everything else in the load order. Generally, preloads load in the order the parser gets to them for anything with `Medium` priority or higher. Be careful if you're including preloads at the beginning of your HTML. Font preloads probably work best toward the end of the head or beginning of the body. Import preloads (dynamic `import()` or `modulepreload`) should run after the script tag that needs the import, so make sure the script gets loaded or parsed first so it can be evaluated while its dependencies are loading. Image preloads have a `Low` or `Medium` priority by default. Order them relative to async scripts and other low or lowest priority tags. History Fetch Priority was first experimented with in Chrome as an origin trial in 2018, and then again in 2021 using the `importance` attribute. At that time it was called [Priority Hints](https://github.com/WICG/priority-hints). The interface has since changed to `fetchpriority` for HTML and `priority` for JavaScript's Fetch API as part of the web standards process. To reduce confusion, we now call this API Fetch Priority. Conclusion Developers are likely to be interested in Fetch Priority with the fixes in preload behavior and the recent focus on Core Web Vitals and LCP. They now have additional knobs available to achieve their preferred loading sequence. Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). For details, see the [Google Developers Site Policies](https://developers.google.com/site-policies). Java is a registered trademark of Oracle and/or its affiliates. Last updated 2023-11-14 UTC.