<link rel="preload" href='./style.css' >
- The preload property enables browser to load resources tha will be required very soon in the page rendering lifecycle, before the main rendering kicks in.
- The call for resources can be prioritised.
- Store in the cache for future requests.
<link type="text/css" rel="preload" href='./style.css' >
- The resource can be preloaded
- The browser can check if it supports such type of resource and should it load it
Source : MDN Docs
Background images and media can be preloaded in order to render images according to screen sizes( if images are conditionally rendered from JS).
`
<title>Responsive preload example</title> <script> var mediaQueryList = window.matchMedia("(max-width: 600px)"); var header = document.querySelector('header'); if (mediaQueryList.matches) { header.style.backgroundImage = 'url(bg-image-narrow.png)'; } else { header.style.backgroundImage = 'url(bg-image-wide.png)'; } </script>`
The resources are loaded which might be needed on the next page. These resources are prioritised below preload
.