As Wikipedia explains:
Link prefetching is a proprietary syntax to give web browsers a hint about documents that it should pre-fetch because the user might visit them in the near future. It is proposed as a draft internet standard by Mozilla. A web page provides a set of prefetching hints to the browser, and after the browser is finished loading the page, and after an idle time has passed, it begins silently prefetching specified documents, storing them in its cache. When the user visits one of the prefetched documents, it can be served up quickly out of the browser's cache.
Firefox introduces a new strategy for website optimization: link prefetching. (learn more about Firefox’s prefetching)
So, what is link prefetching? From the MDN:
Link prefetching is a browser mechanism, which utilizes browser idle time to download or prefetch documents that the user might visit in the near future. A web page provides a set of prefetching hints to the browser, and after the browser is finished loading the page, it begins silently prefetching specified documents and stores them in its cache. When the user visits one of the prefetched documents, it can be served up quickly out of the browser's cache.
It's super easy to implement: the browser downloads designated documents (pages, images, etc.) the user will likely visit after the current page.
Prefetching pages with HTML5
HTML5 introduces prefetching, the art of loading pages before the user requested them. In this post, we are going to discuss this technique as well as showing you some ready to use examples to drastically improve your website loading time.
The only thing you have to do is to place the following code with the <head> and </head> tags of your page. The href attribute have to contain the url of the page to prefetch.
<link rel="prefetch" href="http://www.example.com/">
It is also possible to prefetch an image:
<link rel="prefetch" href="http://www.ma-no.org/assets/img/logos/mano-logo.png">
HTML5 prefetching is done via the LINK tag, specifying "prefetch" as the rel and the href being the path to the document. Mozilla also answers to a few differently named LINK rel attributes:
<link rel="prefetch alternate stylesheet" title="Designed for Mozilla" href="mozspecific.css" /> <link rel="next" href="2.html" />
HTTPS fetches are also supported.
Firefox allows you to disable link prefetching with the following setting snippet:
But when and where is convenient to Prefetch Content?
Well, is up to you! Here are some ideas:
- When a series of pages is much like a slideshow, load the next 1-3 pages, previous 1-3 pages (assuming they aren't massive).
- Loading images to be used on most pages throughout the website.
- Loading the next page of the search results on your website.
Licenciada en Bellas Artes y programadora por pasión. Cuando tengo un rato retoco fotos, edito vídeos y diseño cosas. El resto del tiempo escribo en MA-NO WEB DESIGN AND DEVELOPMENT.
Loading images by resolution with HTML5
Normally the way to load images in HTML is through the img element to which we pass as a parameter the URL of the image to load. But since HTML5…
How to make your own custom cursor for your website
When I started browsing different and original websites to learn from them, one of the first things that caught my attention was that some of them had their own cursors,…
8 benefits of having a website for your business
At this moment, the Internet is a phenomenon that is sweeping the world. It has been able to interconnect millions of users all over the planet. People have made the…
Open source web design tools alternatives
There are many prototyping tools, user interface design tools or vector graphics applications. But most of them are paid or closed source. So here I will show you several open…
We often use webcams to broadcast video in real time via our computer. This broadcast can be viewed, saved and even shared via the Internet. As a rule, we need…
How to Send Email from an HTML Contact Form
In today’s article we will write about how to make a working form that upon hitting that submit button will be functional and send the email (to you as a…
Use the SRCSET attribute to improve your SEO
There is a new standard HTML attribute that can be used in conjunction with IMG called SRCSET. It is new and important as it allows webmasters to display different images…
Something that seems simple as the treatment of dates can become complex if we don't take into account how to treat them when presenting them to the user. That is…
Top tools for UX design and research
This article is a compilation of the "ux tools" I have tested in recent years. I've separated the tools by categories, although I recommend you to take a look at all…