How to make big web pages fast
Stage 6: Expand
Alex Painter
1st September 2015
Share this:

Web pages are getting bigger. According to the HTTP Archive, the average was 2.11MB in July 2015, up from 1.77MB in July 2014 and just 807kB in 2011.

There are a number of reasons for this. A steady improvement in broadband speeds means most of us can cope with more bandwidth-hungry content, such as images and videos. The explosion in third-party services is also having an effect – most retail sites now feature a plethora of third-party scripts and plugins for a range of purposes, including advertising, tracking and social media sharing.

Another recent trend to have had an impact on page sizes is responsive design – a way to make the same web page work just as well on mobile and desktop devices. Although it’s designed to deliver an improved user experience, responsive design can result in bloated web pages.

All of this makes websites slower. More content simply takes longer to deliver. And slow websites make unhappy customers.

It’s not surprising, then, that in the world of web performance, we often home in on reducing page weight. Image optimisation, compression and minification of text files all have a big part to play.

However, these techniques can only take us so far. Site owners are still trying to deliver more and more content. Average page size is still going up.

And while we haven’t given up on trying to minimise page size where we can, there’s now a shift in focus away from cutting the volume of content towards delivering key content early. This is reflected in the way we measure and benchmark performance. Total load time is making way for other metrics, such as Speed Index – a measure of how fast the visible parts of a page are displayed.

So how do we make a big web page appear to load quickly?

Load important content first

One simple solution is to start by loading only the content that’s initially visible when someone lands on the page.

For example, images normally make up a significant proportion of page weight. And very often, only a handful of them are in the end user’s initial viewport. Some of them will be below the “fold” – the part of the page that can’t be viewed without scrolling down. Others might be in hidden carousel slides. And the last thing you want is for the loading of these images to get in the way of other, more critical, content.

One answer is known as lazy-loading. This is a way to load images only as and when they’re needed, for example, as someone scrolls down the page. There are a number of excellent plugins available to achieve this. Do be aware, though, that simply by adding more JavaScript to your site, you are, potentially, affecting its performance. Some lazy-loading solutions can also make scrolling down the page a more jerky, juddery experience. However, if you have long, image-heavy pages, it’s definitely worth testing.

Another option is to focus less on the viewport and more on what visitors are likely to be interested in. For example, on a product page, you might want to make sure that product details are displayed ahead of ads for related products. Again, you can use JavaScript to delay the display of those parts of the page your customers are less likely to care about, allowing key content to appear more quickly.

Screen Shot 2015-08-21 at 14.19.57

Load important styles first

There’s no need to stop at prioritising above-the-fold content. You can also prioritise above-the-fold styles.

A web page can’t begin to display until all the styles (CSS) for that page have loaded. Most web pages include external links to several CSS files, all of which must finish loading before visitors see anything more than a blank screen.

There are two things about this process that can needlessly hold up page display.

The first is that the CSS files typically contain more styles than are actually needed in order to start using the page. These might include styles used elsewhere on the site but not on the current page. Or there might be styles that aren’t used in the initial view of the current page, for example, styles that are only needed for below-the-fold content.

The second issue is that the browser has to download and start working its way through a web page before it finds a link to a CSS file. It then has to request that file, which the server has to return. This takes time.

There’s a simple way to solve both these problems.

The first step is to separate out all the styles needed for the initial view of the page, so that users don’t have to download styles they don’t need straight away. You can then embed these styles directly in the HTML file. This means that all the styles needed to start using the page are downloaded immediately, without the browser having to request an external CSS file.

The result is a web page that displays much faster.

You do of course still need to load all the other styles at some point. You can use JavaScript to load styles needed elsewhere on the page once the critical content is in front of the end user. Styles needed for other pages on the site can be “prefetched” (learn more about prefetching and prerendering here). This is a way to get content required for other pages once everything on the current page has finished loading.

All in all, the page is about the same size as it was before, but it will start to display much more quickly.

It isn’t all good news. One disadvantage of including CSS directly in the HTML is that it can’t be cached separately by the browser. This means that, while the page might be lightning fast on a first visit, on subsequent visits it might actually be slower than it would otherwise have been. It’s therefore worth testing to see if the advantages outweigh the drawbacks.

Don’t let JavaScript get in the way

JavaScript is very useful for adding interactivity to your website. It’s also used to implement various third-party services. The problem is that when a web browser finds a reference to a script, it has to stop building the page while it loads and then executes it. And the more JavaScript you have, the longer this process takes.

This can be a real pain, especially if you have lots of JavaScript on your site. It can leave users staring at a blank screen – or a partially built page – while they wait for the JavaScript to load.

Fortunately, there are several ways to stop it becoming too much of a problem. The simplest is to load scripts asynchronously. This means that the page can continue to be built while the script is loaded. Many – but by no means all – third-party scripts are loaded in this way. It’s also possible to defer the loading of scripts until after everything else on the page is ready.

Conclusion

The trend towards larger retail web pages seems to be here to stay. And load times are getting longer and longer as a result. However, the good news is that having a big web page need not necessarily mean a poor online experience for your customers. It’s still a good idea to minimise page size if you can, not least because many mobile users have limited data plans. But there’s plenty you can do to give the illusion of a fast-loading page and get important content in front of end users early.

  • Was this Helpful ?
  • Yes   No
Author: Alex Painter
Alex Painter is part of the professional services team for NCC Group’s website performance division.
Now read...
Why Your Business NEEDS to Blog
If you have been thinking about setting up a blog of late but you are not sure about whether you can create and sustain a blog or whether you think you can provide value, we are here to help. We aim...
Featured eBooks
Copyright eSeller Publishing Limited © 2014
Connect with us
eSeller Media is the UK's leading channel for learning about selling in the digital age
eSeller partners