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

Automatically moderate your user uploaded images

Allowing your users to upload their own images to your website can increase user engagement, retention and monetization. However, allowing your users to upload any image they want to, may lead to some of your users uploading inappropriate images to your application. These images may offend other users or even cause your site to violate standards or regulations.

Read more
Creating HTML5 Animations

HTML5 is the latest evolution of the HTML standard. It is bundled with a lot of new elements and attributes that makes semantics, connectivity, performance, device access, 2D/3D graphics, animation and styling better on the web.

Read more
Cloudinary Uses Scale API to Focus on Image Compression

Here at Cloudinary, we provide a cloud-based tool that enables our users to compress images and video for their websites and apps. Our goal is to preserve the visual integrity of the content, but deliver the smallest file size to any device or browser to ultimately optimize website performance and end user satisfaction.

Read more
CloudinaryAndroid SDK

Developing applications for mobile consumption requires facing, and overcoming, some difficult challenges. Apps need to limit their RAM, CPU and battery usage while still performing the required tasks in a reasonable time frame. If too many background tasks are running, the mobile device can become sluggish, with the battery running out very quickly. Coordination with other apps is crucial to keep the device responsive and make the battery last longer.

Read more
forLoop: Nigeria Event on Building for The Next Billion Users

TL;DR

Since Google shared their intent for the next billion internet users, some African developers thought this was pointing right at them and they needed to act fast. The mission to bring the next billion users from Africa to the internet kicked off a storm of enthusiasm. This community event turned into a success story and this is a summary of what happened.

Read more