Improving Page Performance with HTML5 Prefetch

Improving Page Performance with HTML5 Prefetch
by Janeth Kent Date: 23-08-2013 html5 Prefetch coding web design development firefox mozilla

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.

There are many common-known ways to keep your websites fast:  using CSS sprites and image optimization, using .htaccess to set file headers for longer caching, javascript file compression, using CDNs, and so on. 

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:

user_pref("network.prefetch-next", false);

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.

 

 

 
by Janeth Kent Date: 23-08-2013 html5 Prefetch coding web design development firefox mozilla hits : 20215  
 
Janeth Kent

Janeth Kent

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.

 
 
 

Related Posts

Alternative tools for graphic design

There are many people today who only use the following for design purposes Canva as it is a really popular software and website and there is no denying that it…

Let's create a Color Picker from scratch with HTML5 Canvas, Javascript and CSS3

HTML5 Canvas is a technology that allows developers to generate real-time graphics and animations using JavaScript. It provides a blank canvas on which graphical elements, such as lines, shapes, images…

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…

How to create a .onion domain for your website

The dark web, a hidden network accessed through the Tor browser, offers enhanced privacy and anonymity for websites. To establish a presence on the dark web, you can create a…

How to access webcam and grab an image using HTML5 and Javascript

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…

Looping through a matrix with JavaScript

We were already talking about how to multiply arrays in JavaScript and we realised that we had not explained something as simple as traversing an array with Javascript. So we…

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…

How to multiply matrices in JavaScript

It may seem strange to want to know how to multiply matrices in JavaScript. But we will see some examples where it is useful to know how to perform this…

Clicky