W3cubDocs

/Web APIs

HTMLImageElement: fetchPriority property

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The fetchPriority property of the HTMLImageElement interface represents a hint given to the browser on how it should prioritize the fetch of the image relative to other images.

Value

A string representing the priority hint. Possible values are:

high

Fetch the image at a high priority relative to other images.

low

Fetch the image at a low priority relative to other images.

auto

Default mode, which indicates no preference for the fetch priority. The browser decides what is best for the user.

The fetchPriority property allows you to signal high or low priority image fetches. This can be useful when applied to <img> elements to signal images that are "important" to the user experience early in the loading process.

The effects of the hint on resource loading is browser-specific so make sure to test on multiple browser engines.

Use it sparingly for exceptional cases where the browser may not be able to infer the best way to load the image automatically. Over use can result in degrading performance.

Examples

js

const img = new Image();
img.fetchPriority = "high";
img.src = "img/logo.png";

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
fetchPriority 102101–102 102101–102 No No 8887–88 preview 102101–102 102101–102 No 70 No 19.0

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/fetchPriority