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 : 18193  
 
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 END DEVELOPMENT.

 
 
 

Related Posts

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…

JavaScript Formatting Date Tips

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…

How to make a multilingual website without redirect

Today, we're going to talk about how to implement a simple language selector on the basic static website, without the need of any backend or database calls or redirection to…

Starting with Bootstrap-Vue step by step

Today we will show you how to use BootstrapVue, describe the installation process and show basic functionality. The project’s based on the world's most popular CSS framework - Bootstrap, for building…

Bootstrap 5 beta2. What offers?

Since the release of the Bootstrap 4 is three years, in this article we will present what is new in the world’s most popular framework for building responsive, mobile-first sites.…

Graphic design and its impact on Web Development

In today's article we will explain the concept of graphic design, its fundamentals and what it brings into web development. Graphic design is applied to everything visual, believe or not,…

Creating simple CSS spinner-loader

In today's article we will show you how to animate a basic loader that spins when some predefined action is defined, such as loading an image. That can be used…

We use our own and third-party cookies to improve our services, compile statistical information and analyze your browsing habits. This allows us to personalize the content we offer and to show you advertisements related to your preferences. By clicking "Accept all" you agree to the storage of cookies on your device to improve website navigation, analyse traffic and assist our marketing activities. You can also select "System Cookies Only" to accept only the cookies required for the website to function, or you can select the cookies you wish to activate by clicking on "settings".

Accept All Only sistem cookies Configuration