A quick performance improvement by giving the browser a headstart with preload
An easy way to ensure that critical content gets rendered fast is to use the preload value on a <link> element. It specifies to the browser that the linked resource will be needed early on in the load.
Here's a straightforward example on how you can use it:
<link href="style.css" rel="preload" as="style">
Placing a preload link in your HTTP header tells the browser to grab this file early, and can be useful for loading important files, such as any critical CSS. Prefetching is similar but is lower priority and designed for resources you might need in future.
This resource hint can be used on a variety of content, including audio, embeds, scripts, videos & more. Browser support is good, but isn't universal. Of course, non-supporting browsers will just ignore the directive and do things the usual way, so it's a win-win.
Looking for a deeper dive on how you can use this to up your performance game? The below links are a great place to start:.
This week's tip is sponsored by CodeFund. Earning funds for your open source projects or tech blogs is now as easy as adding two lines of code to your site. Last month, they paid over $12,000 to devs worldwide. Find out if you qualify.
No comments:
Post a Comment