Faster loading webpages with webP images

Faster loading webpages with webP images:

 Have you ever wondered why your website takes forever to load? It is probably because you are using too large images. The common image types are PNG, JPG, SVG, and GIF. It is time to embrace the modern image formats! Examples are: 

JPEG 2000, JPEG XR and WebP. This article will focus on webP image formats.


WebP is a powerful image compression technology developed by Google in 2010. It focuses on using advanced optimization techniques to reduce file size and it supports transparency and even animation. WebP formats can help compress your images to become up to two-times smaller than JPG images, and this definitely makes the images load faster and hence leading to better website performance. Take a look at this image

This png image has a size of 482.1KB,
The jpeg format has a size of 55.4KB
When converted to webP, the size became 43KB and the quality was still maintained


Firstly, you have to convert your images to webP formats.
Any common file format can be converted to WebP and still maintain their original quality (lossless compression). There are several online image formatters available all over the internet (such as this and this ).
However, as awesome as this is, webP is not supported on all browsers. Firefox for instance, is still working on adding it, but Chrome and Opera fully supports webP images.
This is not a big issue as we can still use this format without breaking our images on unsupported browsers by using fallbacks!

Using webP with Fallbacks

HTML has two image media element (img and picture)
With the picture element you can to load zero to many source elements and one img element. How does this work? The browser will consider each of the image URL in the elements and pick the best match among them. If neither of them is supported by the browser, or if the browser does not even support the element at all, it then selects the image in the tag.


If the browser does not support webP image formats, the JPG image is loaded.

To avoid the clumsiness, (as this seems like too many lines of code in my opinion, lol) you can create a component for this. Using ReactJS,

const ImageWithFallback = ({
  type = 'image/webp',
}) => {
  return (

So, whenever you want to add an image in your code, you can easily import the ImageWithFallback component and use as an image tag. Keep your code tidy 🙂

In conclusion, your website speed is a very important factor, and using webP image formats can help you achieve faster loading images with equal good qualities.

from Tumblr

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s