Cloudinary Blog

How to get media to load faster on your website

By Kasia Kramnik
Tips and tricks to help your website's media load faster

This is a guest post by Kasia Kramnik, Content Marketing Manager at Netguru, a full stack development house and one of Cloudinary's Consulting partners.

Take a look at your website. Are you happy with the way it looks? I bet you are, and that’s really awesome. Keep in mind though, there is one thing you can’t actually see, but you need to experience: the load speed. Sometimes the most important element is invisible to the eye. In this article you’ll find tips on perfecting the invisible as well: loading your site and media with visibly better results.

Why is fast loading important anyway?

The reason is simple and it should be crucial to you: your users. They get impatient, they have a low attention span, and they won’t hesitate to leave your website if they have to wait. You may grumble about how hasty your potential customers are, but that’s exactly the challenge: dealing with their tendency to abandon anything that requires patience. One of the online surveys conducted on 2,500 online consumers in the US and UK found that 67% of UK shoppers and 51% in the US admit that a site's slowness is the top reason they’d abandon a cart in an online store.

It’s also worth noting that Google has incorporated site load speed into a list of factors influencing the search ranking position. It seems like there are enough reasons to take a closer look at loading times, but what if the results are far from excellent? How can you speed your page up? Here are a few tips regarding media upload, management, and storage.

Save images for the web

The process of load speed optimization starts before the images actually land on your page. When you’re working on your images in any sort of graphics tool, make sure you save them in a format that’s compatible with web publication. This limits the amount of metadata carried on an image and makes it easier to edit the image quality.

What formats are applicable for the web? There’s a variety of options:

  • Scaleable Vector Graphics (.SVG) - preserves its quality no matter the size on screen, best for logos; lossless.
  • Portable Network Graphics (.PNG) - best for high-resolution, detailed graphic images you want to present in full quality; lossless.
  • Graphic Interchange Format (.GIF) - for simple animations; lossy.
  • WebP - an image format supported by Chrome browsers; either lossy or lossless.
  • Joint Photographic Experts Group (.JPEG or .JPG) - best for scalable images; lossy.
  • JPEG-XR - an improved variation of JPEG format supported by IE browsers, suitable for scalable images; lossy.
  • JPEG2000 - a higher-quality JPEG format supported by IE browsers; lossy.

Format comparison example:

196 KB in PNG format:

 PNG format

https://res.cloudinary.com/demo/image/upload/w_400/turtles.png


25.2 KB in JPEG format with 80% quality:
 

JPEG format

https://res.cloudinary.com/demo/image/upload/w_400,q_80/turtles.jpg


20.1 KB in WebP format with 80% quality: 
 

WebP format

https://res.cloudinary.com/demo/image/upload/w_400,q_80/turtles.webp

 ‘Lossy’ vs ‘lossless’ file formats

While some file formats are very prone to lossy formatting, i.e. altering or losing any original information from the source file, media files are perfect material for lossy formatting. Our eyes are not able to receive all the information coded in every pixel, which means you can easily cut down on redundant data and decrease the file size.
 
For ‘lossy’ formats, the formatting eliminates some pixel data completely. For ‘lossless’ formats, the pixel information is compressed, but still maintained. Typically, ‘lossy’ formatting enables more options for file quality and size.

Work on image size and quality

Image and video file formats have various properties, including their sizes. Some of them might be suitable for all devices, others will only load well on desktop screens, and not all of them are suitable if you want to reduce your page load speed. Also, the image quality required for different screens will vary.
 
What can you do to make sure you use the best file format and quality for optimal load speed? Of course, there are a variety of tactics to use, but these will enable you to start in the right place:
  • Scale or crop images to match the display size. These are typical elements of responsive design, but since it’s not just about being responsive, you’ll find more about it in the next section.
  • Adjust image quality to match the screen resolution. The lower the quality, the smaller the file size. Remember to use lossy formats!
  • Convert lossless formats into lossy, e.g. replacing a PNG (lossless) file with a lower-quality (let’s say 70%) JPG image. Another example: you can decrease the size of animated GIFs when converting them to WebM or MP4 formats.

Think mobile-first 

Picking the right approach to design will definitely help you change the way you perceive the role of images on your website. But what’s the practical difference between desktop-first and mobile-first? Let’s explain with a comparison.
 
In a desktop-first approach to front-end development and web design, you start from the version of your website that uses heavy components by default. You get used to the thought that putting them there is kind of natural and obvious. Then, when designing the same website for tablets and smartphones, you wonder what elements you need to reduce to make things still work. This approach is also called graceful degradation.
 
On the other hand, the idea behind mobile-first front-end development and web design works on a precaution that the website should give you maximum necessary content with minimum space and weight. You obtain this effect, for example, by using responsive, scalable images and quality adaptable for particular devices. By starting from mobile and progressively enhancing for tablets and desktops, you reduce redundant elements.

Wrapping up

Load speed is crucial for your website conversion and search rank. To optimize it, you may experiment with file formats, scaling, adjustable quality, and other factors. Remember the difference between lossy and lossless formats, and make sure you use each format according to the file’s purpose. Also, pay attention to mobile-first design, as it will help you create more efficient, faster-loading sites.
If you’re using Cloudinary, your worries will be limited to uploading the best-looking picture - all image cropping, conversion and optimization is accomplished with dynamic delivery URLs. You’ll find more info on Cloudinary's Features page.
 
P.S. If you would like to test your page load speed, this list of testing tools will definitely help!
 

Recent Blog Posts

Generate Waveform Images from Audio with Cloudinary

This is a reposting of an article written by David Walsh. Check out his blog HERE!
I've been working a lot with visualizations lately, which is a far cry from your normal webpage element interaction coding; you need advanced geometry knowledge, render and performance knowledge, and much more. It's been a great learning experience but it can be challenging and isn't always an interest of all web developers. That's why we use apps and services specializing in complex tasks like Cloudinary: we need it done quickly and by a tool written by an expert.

Read more
Make All Images on Your Website Responsive in 3 Easy Steps

Images are crucial to website performance, but most still don't implement responsive images. It’s not just about fitting an image on the screen, but also making the the image size relatively rational to the device. The srcset and sizes options, which are your best hit are hard to implement. Cloudinary provides an easier way, which we will discuss in this article.

Read more

The Future of Audio and Video on the Web

By Prosper Otemuyiwa
The Future of Audio and Video on the Web

Web sites and platforms are becoming increasingly media-rich. Today, approximately 62 percent of internet traffic is made up of images, with audio and video constituting a growing percentage of the bytes.

Read more

Embed Images in Email Campaigns at Scale

By Sourav Kundu
Embed Images in Email Campaigns at Scale

tl;dr

Cloudinary is a powerful image hosting solution for email marketing campaigns of any size. With features such as advanced image optimization and on-the-fly image transformation, backed by a global CDN, Cloudinary provides the base for a seamless user experience in your email campaigns leading to increased conversion and performance.

Read more
Build the Back-End For Your Own Instagram-style App with Cloudinary

Github Repo

Managing media files (processing, storage and manipulation) is one of the biggest challenges we encounter as practical developers. These challenges include:

A great service called Cloudinary can help us overcome many of these challenges. Together with Cloudinary, let's work on solutions to these challenges and hopefully have a simpler mental model towards media management.

Read more

Build A Miniflix in 10 Minutes

By Prosper Otemuyiwa
Build A Miniflix in 10 Minutes

Developers are constantly faced with challenges of building complex products every single day. And there are constraints on the time needed to build out the features of these products.

Engineering and Product managers want to beat deadlines for projects daily. CEOs want to roll out new products as fast as possible. Entrepreneurs need their MVPs like yesterday. With this in mind, what should developers do?

Read more