8+ Handy Tips To Optimize Images In Magento 2 for Lighter Website

How to optimize images in Magento 2? Stay tuned to grasp 8+ handy tips! 

As you may know or not, images usually contribute to most of the downloaded bytes on a web page. Therefore, image optimization can often obtain some significant byte savings for Magento 2 websites and finally improve store performance. 

This benefit of Magento 2 image optimization can be explained when the browser has to download fewer bytes, which results in less competition for the user’s bandwidth and the browser can download and render content faster on the screen. 

Stick around with us in this post and save 8+ practical tips to optimize images in Magento 2.



LEARN MORE TIPS via 25+ Swift Tips for Magento 2 Speed Optimization to enhance the overall store performance.  

8+ Practical Tips to Optimize Images in Magento 2

1. Compress images 

Compressing images could be the first tips you think about to decrease image size. Though this action will reduce image quality, it’s worth the sacrifice to reach a balance between file size and quality. 

When you use uncompressed PNGs, JPEGs, and GIFs, they create a huge overhead on the website. For this reason, all of them should be properly compressed by one of these 3 ways: 

  • First, try to use available tools like Imagemin, libvips, WebP Converter to convert your images into a more efficient format. These tools are server-side and operate exactly as you’d expect. 
  • Second, you can reduce image size via TinyPNG (optimizes by 50%-80%), TinyJPG, ImageOptim, or similar tools before it is uploaded on your website.
  • Finally, the Content Delivery Network (CDN) offers smart image compression without changing the original image on the server. The CDN will compress that image in their own server instead and store it there within the cache.

2. Use image CDNs 

Image CDNs are used to transform, optimize, and deliver images. You can also think of them as APIs access and control the images used on your site. For images loaded from an image CDN, an image URL specifies which image to load and parameters such as size, format, and quality. This makes it easy to generate variations of an image for different use cases.

Using image content delivery networks (CDNs) is an excellent tip to optimize images in Magento 2. This method can yield a 40–80% savings in image file size. Although this result can be achieved using only build scripts in theory, but it’s unusual in practice.

If you are seeking a CDN service for Magento websites, Cloudflare, Fasty, Amazon CloudFront are typical companies that you can search for the best offer. 

3. Use lazy loading for non-critical images 

This is one of the most practical tips to optimize images in Magento 2. 

Lazy-loading is a technique in which a load of non-critical images can be deferred at page load time. Instead, these images are loaded when needed. In most cases, “non-critical” images are “off-screen” images, which means they will only be loaded when users scroll to the section they involve.   

The use of lazy loading becomes more meaningful when users visit your website with a slow mobile network and tight bandwidth because they can experience significantly faster loading where it matters. 

In a nutshell, this practice improves your website’s performance while creating no drag on your server resources.


GRASP FREE EXTENSION for Magento 2 Lazy Load feature to reduce loading time for better Magento performance! 

4. Do not use images larger than you need 

Using images larger in size than you really need is such a bad practice that will hurt your Magento page speed because they quickly add up and can result in noticeable overhead for your website. The larger the image is, the more pressure your server has to handle.

As a result, browsers have to scale these kinds of images on their own – which leads to lower visual quality and slowdown delivery speed.

The ideal size of an image in Magento 2 should not exceed 1920px high and 1200px wide. That’s why Magento will distort any picture larger than this size. Therefore, make sure your images do not break this rule before you upload them to your site.   

5. Use responsive images 

With the requirement of responsive design, the “one-size-fits-all” approach is not suitable. Instead, it’s necessary to serve different image sizes to different devices. The sharp npm package is one of the most popular image resizing tools that can be used for this purpose. 

So, how many image versions should you create? 

There is no correct answer to this question. However, you should prepare 3 to 5 different sizes of an image. But remember that the more versions you serve, the more space they will take up on your servers and more HTML are required. 

6. Replace animated GIFs with video 

Animated GIFs have won the hearts of online users than any other digital file format and commonly used to replace images for more vivid effects. However, they are often huge files and so hard to optimize, which consequently slow down your pages. That’s why we can see services like Giphy don’t even use the GIF file format themselves. Instead, they use HTML5 videos that are often as much as 90% smaller in size. 

By converting large animated GIFs to videos, you can save big on user’s bandwidth and improve the site performance. 

7. Replace images with CSS3 styles

CSS3 is the latest update of CSS (Cascading Style Sheets language). It far exceeds many people’s expectations with a lot of improvements over CSS2. For example, it can handle shadows, animations, and gradients for any screen size, device, or zoom level. Furthermore, CSS3 can handles basic geometry creation very well. 

Thanks to those strengths, replacing some images with CSS3 styles is totally possible and offers a great vector of speed optimization and performance enhancement. The more replacements you do, the more impact you will see to optimize Magento 2 speed.

8. Make your images SEO-friendly 

Last but not least, don’t forget to follow the best SEO practices if you want all of your images to be optimized. This step obviously does not impact the store performance but influence your ranking on search engines. 

Anyway, it’s always better to make sure your images pass these SEO requirements: 

  • The ALT tag of images cannot be missed and must be readable 
  • The image names are clear

Bottom Lines 

Whatever tips you are using to optimize images in Magento 2, all of them with the above tips service the key goal: to accelerate Magento speed and improve store performance. Hence, it’s good to combine all tips you’ve learned to reach your goal faster. 

However, Magento speed and overall performance optimization are more than image optimization. For a more comprehensive solution, Magento 2 Speed-Up Consulting Package will help you approach expert advices. REACH NOW to request dedicated support. 

BSS Commerce is one of the leading Magento extension providers and web development services in the world. With experienced and certified Magento developers, we commit to bringing high-quality products and services to optimize your business effectively. Furthermore, we offer FREE Installation – FREE 1-year Support and FREE Lifetime Update for every Magento extension.

CONTACT NOW to let us know your problems. We are willing to support you every time.

Content Writer at | Posts

Hi there! I’m Summer. I’m a big fan of business, ecommerce, and technology-related topics and now working as a Content Writer at BSS Commerce. It’s such a great experience to share useful pieces of content for those who concern. This generates the motivation for me to read more and write hard.

Write A Comment