Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How To Optimize Your Images For Magento 2

Even if you have limited capital, you can still set up a business on the internet and sell products. With the consistent reliance of customers on online shopping, it’s been estimated that almost 95% of purchases will be online by 2040. Owing to this, Ecommerce opens a myriad of doors of opportunities for entrepreneurs across the world.

However, if you’re thinking of coming up with a store on Magento 2, keep in mind that your game will excessively revolve around visuals. Be it content on social media or product images; your online buyers want to see what they’re buying and engage thoroughly with the site before making a decision. In fact, a study stated that 3D product images could increase conversion by up to 250%. 

However, there’s a crucial issue with these images. They end up slowing down the website. After all, the more the number of images on the site, the higher will be the load time. But, don’t worry. You still have a way to deliver both attractive and fast websites. And that is through image Optimization

So, in this post, let’s find out how to optimize your images for Magento 2 to decrease the load time and attract more and more customers.

How to Optimize Your Images for Magento 2?

Without further ado, let’s find out here how you can optimize the images for Magento 2 eCommerce store. 

  • Compress Images So They Load Faster

Uncompressed GIFs, JPEGs, and PNGs can create huge overheads on your website. The bigger the picture, the more benefits you’ll get from compressing it adequately. When it comes to compressing images, a lot of people fear losing the quality. Know that it’s not as depraved as it may sound. 

If you avoid overdoing it, lossy quality will eradicate concealed elements of the picture that don’t impact the apparent image quality. One of the undeniable things that you cannot overlook is that the eCommerce space sells solely through images. 

When you’re trying to convert visitors into customers, pictures can be a powerful tool in convincing the users. Losing the quality of images to a point where it’s noticeable shouldn’t be an option at all. 

So, if you’re going with lossy, it’s recommended that you choose 82% of lossy image compression. There are three primary ways to compress the eCommerce store’s images, such as:

  • Compressing Pictures in the Store

To begin with, you can compress images inside your eCommerce store. For this, you can use a variety of tools, such as WebP Convert, libvips, imagemin, or any other. These tools are server-side and work according to your expectations. If you’re looking for SaaS solutions, you can choose Cloudinary or its alternatives. 

  • Compressing Images Before Uploading Them

The next option is to use tools like ImageOptim, TinyJPG, and TinyPNG to optimize the images before uploading them. However, if you choose to go with this option, you’ll have to invest some more time and be disciplined to optimize the images and use these tools effectively. While manual optimization is free, you’ll have to pay the price if you want automation.

  • Compressing Images Using a Content Delivery Network (CDN)

The third option here is the Content Delivery Network (CDN). The unsurpassed CDNs provide smart image compression as an extra perk of the subscription. Here, Polish by Cloudflare is a good example. 

A good CDN is capable of boosting numerable inbuilt image optimization features. You should be smart enough to use one to your own advantage. With a capable CDN, you can be benefitted greatly from caching, optimization, and the delivery of media assets.

Some CDNs can even provide conversion to modern image formats, such as JPEG 2000, JPEG XR, and WebP. You can even grab latency reduction, on-the-fly compression, and more. 

However, one of the disadvantages of this option is that it won’t change the original image on the server. The image will stay just the way it is. Rather, the CDN compresses the image in its own server and keeps it there in the cache.

Any visitor to the store will get to see a cached optimized image, which decreases the use of bandwidth and improves their browsing performance. CDNs can provide images in WebP to adequate web browsers. 

Based on the browser type that your visitor is using, your CDN will showcase either a newer version of the WebP’s file or the older JPEG. But, if the CDN cache turns annulled, the CDN will be compelled to provide the original unoptimized image until a new cache is built.

Recommendation:

You can merge a server-side tool with an efficient CDN to get the best of both worlds. This way, you’d be able to effortlessly compress the existing images and get to make the most out of CDN image caching. 

  • Switch to Modern File Formats

The latest and more competent formats provide noteworthy performance savings. For instance, WebP can save up to 30% in comparison to JPEG 2000 and JPEG. Moreover, it doesn’t lose any image quality either. 

Currently, WebP also offers extensive support to a majority of mainstream browsers, such as Chrome, MS Edge, Android, Firefox, Opera, and more. Additionally, if you’re using a competent CDN, you wouldn’t have to switch to WebP.

In case you don’t wish to use a CDN for the new format delivery, you can perceive WebP images support on your own. And then, you can serve WebP to the target audience through HTML5 element.

Keep in mind that if you’re trying to host a second version of each image in WebP format in your Magento store, you’ll require approximately twice as much data storage as you’re already using. So, cautiously evaluate your cost of infrastructure and the unavoidable increase in data storage investments before integrating anything. 

In addition to this, there are varying types of image files as well, like GIF, PNG, and JPEG. To run successfully in this digital era, it’s essential that you have a basic knowledge pertaining to these file types to comprehend the type that will be more advantageous to you and take up less space on the site. 

Here are some of the basic things to know about these file formats:

  • Joint Photographic Experts Group (JPG/JPEG)

Unlike other types of files, JPEG files can effectively mix green/red/blue lights that let you display a variety of colors. You can also adjust the file size when in JPEG format. Thus, this type is adequate for large image files as they download faster if the file’s size is adjusted correctly without quality degradation. Moreover, this format is ideal for images with multiple colors and photography images. 

  • Portable Network Graphics (PNG)

PNG is one of the latest image file types. They are large in size and offer better quality as compared to JPEG files. But, PNG-8 doesn’t offer better quality as it lets you display up to 256 colors. On the contrary, PNG-24 lets you display millions of colors and ensure the right quality. This file type is ideal when the image file’s quality is more important than the size. However, it’d be better if you use this format for simpler images.

  • Graphic Interchange Format (GIF)

Believe it or not, it’s surely fun to have some GIF elements on an eCommerce site as they are compressed versions of images or videos. But, they can only showcase 256 colors. Thus, the GIF file type is ideal for small images (thumbnails/icons), images that have limited colors (logos), and animations. 

  • Lossy vs Lossless Optimization

Lossy compression is a technique that helps restore larger files to their original form with the loss of some unnoticeable data. On the other hand, lossless compression helps in restoring large files to their original form without losing any data. 

Here’s a brief comparison between lossy and lossless optimization to understand both of these concepts.

ComponentsLossy OptimizationLossless Optimization
Elimination of DataThis one eradicates the bytes that are regarded as unnoticeable.This one keeps everything, even the unnoticeable bytes. 
RestorationOnce lossy optimization is done, an image cannot be restored to the original formOnce lossless optimization is done, an image can be restored to the original form
QualityLossy optimization results in comprised qualityLossless optimization doesn’t degrade the quality
SizeIt decreases the size of an image considerablyIt decreases the size but less than lossy optimization
Algorithm Used1. Transform coding
2. Fractal compression
3. Discrete cosine transform
4. Discrete wavelet transform

And more
1. Run length encoding
2. Arithmetic encoding
3. Lempel-Ziv-Welch
4. Huffman coding

And more
UsesIt’s used to compress images, video and audioIt’s used to compress sound, images, and text
CapacityIt has high data holding capacityIt has low data holding capacity
  • Resizing Images to Scale

A primary thing to keep in mind is that the image size measurement is different from the file size measurement. The image size is the dimensions of the images, like 1280×720 or 852×852. But, the file size is the space that is required to store images on the server along with the image’s loading speed which is directly proportional to the image size.

Thus, it takes a long time to download those images that have large file sizes. Hence, the performance of your eCommerce site is extensively based on the image’s file size. So, it’s essential that you keep the size of images within 1-2 MB as it helps increase the loading speed of the webpage and decrease the bounce rate. 

Another primary parameter that impact the Magento image size is the resolution, meaning the number of pixels available in the image. It can be discovered by the width and the height of the picture and the total number of pixels. For instance, an image that is 1920 px in height and 1080 px in width will comprise 2,073,600 pixels or 2 Megapixels.

The rule is to first concentrate on the Magento 2 image sizes for a result-oriented Magento 2 image compression. Presently, there are three primary ways to do it:

  • Retain the Aspect Ratio of the Original Image

The proportional relation of the width to height is known as the aspect ratio. Usually, it’s written as two numbers that are separated by a colon, such as 2:2, 4:5, 17:10, etc. One of the common problems with an eCommerce store is that the uploaded pictures of the products, as well as the product images on the web page, have varying aspect ratios.

Let’s suppose you’ve taken a picture of a certain product. The size of the image is 1920 px in height and 1080 px in width. Thus, its aspect ratio will be 16:9. The dimensions of the product pictures on your eCommerce store will be limited by CSS. And, if it’s standing at, for example, 600 x 600, its aspect ratio will be 1:1. 

As you can point out, the aspect ratio of the original image and the product image are not the same. This is why the uploaded picture will become distorted if it has to fit into the aspect ratio of the product image. 

In the end, the distortion will be reflected by pixelated or grainy or a blurring appearance. Apart from being unclear and coming up with weird, distorted images, don’t offer a good impression of the products you’re selling, which ultimately impacts your conversion rate. 

So, how can you change the product image size and keep the images looking good?

One of the best solutions is to retain the aspect ratio of the original product image the same as the aspect ratio of the resultant image. 

  • Using Image Compression

A well-considered perception says that it’s highly vital to compress images without losing the quality. As mentioned above, by now, you’d know the importance of using compressed images on your eCommerce store. Presently, you can find an extensive range of solutions, such as online tools and Magento image optimization extensions that can help compress pictures delicately. They offer a significant reduction in size without deteriorating the quality. 

Here are some options to consider for this factor:

  • Extensions

By using some of the most successful Magento 2 image optimization extensions, you can easily achieve quality performance optimization.

  • Command-line Tools

You can use the extremely popular command-line tools as they work by reorganizing the compressed data and circumventing the complete decoding of images. The best thing is that the transformation happens without any casualty, and you get to retain the best possible quality.

  • Avoid Making Magento 2 Images Excessively Large

The Magento eCommerce platform comes with its own set of requirements as far as the product image size is concerned. Magento 2 image sizes shouldn’t be more than 1920 px in height and 1200 px in width. This is the reason why Magento distorts images that have dimensions beyond these numbers. Also, it’s difficult to anticipate the way images will get distorted. So, keep this factor in mind when adjusting the size of images and adding pre-sized images to the site.

  • Enable Progressive JPEGs

Another significant image optimization strategy for Magento 2 is enabling the Progressive JPEG. This image format lets the browser load qualitatively instead of quantitatively. In simple words, it loads the images slowly, little by little, thus, improving the quality of images to 100%.

To compare, refer to these images displayed below and see how a regular JPEG generally loads. 

On the other hand, now you can see how a progressive JPEG picture generally loads. 

Though it’s been a while since progressive JPEG has been around, not many websites are using this technology. To tell you the truth, the difference between progressive JPEG and sequential JPEG may not be obvious on computers that are using a suitable internet connection (say more than 100 Mbit per second).

In such a scenario, the browser will load the images quickly, and they’ll be downloaded almost promptly in their maximum quality. However, if the connection is weak (such as a mobile connection) or in case the image is too large, the difference will be apparent. 

Clearly, when every nook and corner of the world is equipped with the fifth-generation internet, the difference between the progressive JPEG and the usual JPEG will not be there. Since we aren’t there yet, you can switch to progressive JPEG to improve the overall performance of your store.

There is a variety of ways how you can save the image in progressive JPEG format. The easiest of them is through jprg.io – an online service. Moreover, you can configure your server or use a third-party plugin. 

  • Use Vector Images Where Possible

Remember, clean design is always fast design. This may sound unimportant at the beginning. But, for a while, step back and take a glance at your design. Are there any pictures you can get rid of? Is there anything you can replace with CSS, fonts, and vectors?

Unquestionably, you can speed everything else with an efficient CDN along with a smart lazy loading configuration. However, the best step here would be to make the store lighter and cleaner.

SVGs provide a better quality of image, smaller file size, and adequate scaling to any resolution. Sure, they won’t be appropriate for each image, but you can use them in the places where vectors, icons, and other UI elements can shine out. 

With vector images, you can enjoy:

  • Efficient design responsiveness
  • Zoom-friendly images
  • No loss of detailing

And much more. 

Along with a smaller size, you can also make SVGs consume less space when you minify them and Gzip compresses them. Such steps take out SVG images from comments, namespaces, and metadata that end the picture without providing any value to the visitors. 

Additional Tip:

You can add SVG UI elements to a custom font and load both of them as a single file. This bundling type will decrease the number of separate requests on a page and enhance the performance of the page speed. However, this advice is more valuable for the ones who’re still sticking to HTTP/1.1 and not much use for those who’re using HTTP/2 and QUIC protocols.

  • Defer Image Loading to Clear Critical Rendering Path

Deferring image loading is an added strategy in Magento to optimize the pictures. It will assist you in decluttering the Critical Rendering Path, thus, improving the Magento TTFB and speeding up the entire performance. This can be done with a lazy loading script that comprehends how images (whether photos, gifs, or other media) will appear on the screen.

Basically, this one is a prioritization tool that substitutes pictures outside the viewport with placeholders, and the media available in the viewport loads normally. Your visitors won’t get to experience any negative effects from this reshuffle of loading priorities happening behind the scenes. However, simultaneously, they’ll experience faster loading wherever it matters. 

Visitors on slow mobile networks, older devices or tight bandwidths will instantly observe an increase in performance. On the other hand, those who are navigating the site on smartphone flagships and are using 4G+ speeds of the internet will see a slight boost in the performance but nothing substantial.

Lazy loading is one of the regarded tools available, considering it enhances seeming performance without forfeiting anything. You won’t require additional RAM or CPU to integrate it. Moreover, it’s SEO-friendly as well. You’ll save a lot of bandwidth with those visitors who don’t scroll till the page end. By implementing lazy loading correctly, you can improve the overall user experience without affecting the server resources. 

However, keep in mind that you avoid using lazy loading for the largest element available above the fold. This way, you may end up negatively impacting the LCP score and the overall performance of your site. You can easily lazy load every element that is out of view, even the logo and menu icons. But, make sure you don’t involve the LCP element in this method and are opting for a basic picture or img tag. 

  • Enable Fastly Image Optimization

Also known as Fastly IO, this specific Magento 2 image compression technique is used to make image delivery faster. It’s an adequate choice for handling a variety of image formats, such as GIF, PNG, and JPEG. Some of the major benefits of Fastly include:

  • Resizing product images from lossless to lossy
  • Using adaptive pixel ratios for varying screen resolutions
  • Driving lossy conversions

To make Fastly run perfectly on your store, you’ll have to enable, configure and verify it. If you come across any difficulties when configuring Fastly for image optimization, you can get professional support. 

Fortunately, Fastly comes with flexible settings. On the basis of the chosen options, you can specify the extent to which you’ll let images lose their quality during the compression. Once you begin using this tool, it’ll make more sense to authenticate it. You’ll be able to test the store as far as web speed is concerned. 

  • Set Static Cache Expiration to One Year

For most files on an eCommerce store, Google PageSpeed Insights endorses 1-year static cache. It’s obviously good advice, specifically if you’re already controlling the versions with filenames. This change is adequate to make sure new files are updated correctly and not stuck in the older version as the browser is incapable of recognizing it as new and uses the browser cache rather than getting the new visuals.

With the help of longer cached images, you’ll get to save bandwidth, enhance the browsing experience for those returning to your site, and make Google PageSpeed Insights content. Most often, an adequate CDN will provide a longer cache lifetime by default and can handle this setting to an extent for you.

The only change you’d have to do is set Cache-Control: max-age=31536000 for the images to one year. 

  • Use Multiversion Images Based on Screen Size

Responsive design provides new opportunities and challenges to Magento developers. One such opportunity is the usage of an array of image versions for distinct screen resolutions. Magento can display you the image’s version that suits the display in the best manner based on your viewport. 

For instance, narrowing the screen to 240-pixel wide from 960-pixel wide will compel the server to switch from a broader image to a narrower one as elements will bundle up together and will have to look for their place in the changing layout. 

   alt=”image alt text” 

   src=”medium.jpg” 

   srcset=” 

      small.jpg 240w, 

      medium.jpg 300w, 

      large.jpg 720w

   ” 

   sizes=” 

      (min-width: 960px) 720px, 

      100vw 

   “

>

There’s another implementation to this and it’s the tag. Along with improving the responsive designs and optimizing images for varying viewports, HTML5 lets you list several alternative image sources for an individual file in the priority order.

  

  

  

You can choose either of these methods. While the srcset method is a bit heavier, the tag method has the benefit of simpler testing. You can effortlessly get a smaller device with software installed and evaluate how the design works.

Also, avoid using images that are larger than the requirement. Consistently loading such images that are large in size is a bad practice. Extra data quickly adds up based on the size difference, and there could be obvious overhead. The larger the file, the more unwanted pressure it will put on the server as far as the bandwidth is concerned.

Browsers have to scale such images on their own, which results in decreased visual quality and slows delivery speed. 

  • Replace Images with CSS3 Styles

CSS3 is capable of coping with a lot more than people anticipate. If you replace a few images with CSS3 styles, it will provide a significant vector of optimization. These styles are competent enough when it comes to handling gradients, animations, and shadows for every screen resolution, zoom level, and device.

CSS3 can help with basic geometry creation as well. In the example mentioned below, you get to see how you can build the same complicated geometrical figure and apply the gradient to it through CSS rather than SVG.

By replacing such elements with CSS, you can easily boost the speed of your site and provide performance benefits. The more substitutions you can make, the better impact it will create on optimizations.

For instance, using the code mentioned-below, you can easily come up with CSS figures. With this example, you can make gradient rectangles and an upside-down black triangle. 

#my-circle {

      width: 60px;

      height: 60px;

background: black;

      border-radius: 50%;

}

#my-hamburger-container{

  height: 30px;

  width: 30px;

  padding: 15px;

  display: flex;

  flex-direction: column;

  justify-content: space-between;

  background: black;

  border-radius: 50%;

}

#my-hamburger{

  height: 5px;

  background: white;

  border-radius: 5px;

}

As a result of this CSS code, you’ll get this:

  • Remove Text on Images

Astonishingly, there are still a variety of images with text around the internet. Believe it or not, if you do the same, it’s a bad decision that you’re making. Generally, images are non-searchable, heavier, and bad for text.

As you try and implement different Magento 2 strategies to optimize images rather than pictures, you can make use of real text written in quality fonts. This way, it will be a high-DPI device and SEO-friendly, accessible, zoomable, selectable, and searchable. 

  • Mobile-First Image Optimization

On July 1, 2019, Google finally announced a complete switch to mobile-first indexing for new websites. Although this search engine began promoting mobile-first UX as a top priority a long time ago, the switch happened fairly recently. 

This is again a good idea because, in comparison to other devices, mobiles have less screen real estate, bandwidth, memory, and raw CPU power. One of the primary reasons is that more than approximately 50% of visitors navigate the website on mobile, and this number is growing consistently. Thus, for Google, it’s vital that the site is convenient to use on mobile.

When you run an eCommerce store, Google expects you to develop a consistent user experience for all the platforms. So, everybody will have a fair win when you’ve optimized images on Magento for mobile. 

Optimizing images for the punier device first can provide advantages to the robust devices too. Moreover, even the desktop version of your store will gain benefits from a more responsive and lighter design that focuses solely on adequate content visibility, minimalism, and speed.

  • A Lighter Design for Mobile Visitors

Do you have ten fancy carousel sliders on your eCommerce site? Are you sure they’re worth it? How about if you have a glance at the analytics? How about popups, decorative scrollbars, and other DOM elements? All of these elements can kill the mobile performance of your site.

It’s completely understandable that online retail is a visual-focused industry and has to showcase thousands of products. This image-dominated situation can negatively affect your store performance, specifically for mobile users. 

So, to maintain the speed levels, you must concentrate on delivering lightweight and straightforward mobile designs. It comprises eliminating all the resource-heavy elements. 

  • Hardware-Accelerated Content

The older is the phone, the slower it will work with animations. One solution here to run animations faster on mobile devices is to switch the translate CSS function used to translate3d(). 

By doing so, you’ll ensure that rather than a software acceleration, your browser will unswervingly use the phone’s hardware to process the animation. Smooth animation is one of the keystones of adequate speed and performance since visitors are delicate to lag. 

  • Use Images of a Right Size

Both desktop and mobile users will gain an advantage from this Magento image optimization. You must upload pictures of the precise size you require as it will save bandwidth and enhance the user experience. 

You may think that a few extra pixels cannot get you into a problem. But imagine this scenario where you have hundreds of large images, say in a product grid. This is where the performance will affect the entire mobile navigation. By uploading images of the correct size, you can avoid this situation. 

  • File Names and the Impact on SEO

Of course, there are specific images on each eCommerce website, like design elements, that don’t have to appear on search results. But, it’s essential for a lot of the images displayed on your store to come up in search results. To ensure this, you’ll have to resolve all the problems and issues to make the standards adhere to the latest SEO foundations. 

When you’re optimizing images, you must ensure that they’re easy to index and easy to find. In simple words, optimize Magento 2 images by keeping Search Engine Optimization (SEO) in mind. Google is getting clever with each passing day. Thus, it makes sense that you take the SEO aspect into account when conducting the image optimization process on the site. Here are a few points to keep in mind:

To begin with, ensure that the image filename is adequate. When crawling the text on webpages, search engines focus on the name assigned to the image files amidst other factors. This is the reason why you must keep the names of files keyword-rich and descriptive. Make sure you avoid generic file names, like IMG000023. It’s recommended to turn a bit more descriptive here. For instance, if it’s a red rose that you’re selling, you can name it “original-red-rose.jpg”. In simple words, you must assist Google in understanding your images and what you’re selling. 

To write an effective filename, follow these below-mentioned points:

  • Avoid the usage of multiple keywords in the filename
  • Use hyphens or underscores in between the words, as Google will be able to read through the filename easily
  • Avoid the use of space as this will make the filename illegible
  • Make sure the naming agreements are transparent to search engines and visitors
  • Use descriptive information and words that your target audience will be searching when conducting an image search rather than adding any hexadecimal labeling

Apart from this, image URL also impacts the SEO foundation significantly. So, when you create the URL for the image, it’s vital that you keep the following points in mind:

  • Use the primary keyword in the URL. But, make sure you avoid the use of the same keyword in the image filename
  • Ensure that a correct URL architecture has been followed for all the image URLs
  • You can create subfolders for varying types of pictures, such as images/t-shirts/men, rather than creating one standard folder, like /images/
  • You should also create a hierarchical taxonomy for picture URLs as this will help search engines to have an excellent semantic comprehension of images
  • Data URIs and Base64-Encoding Images

Data URI is one URI scheme that lets you embed almost any type of data into HTML pages. This means that you get to insert the file’s contents rather than specifying the file’s URL. For instance, you can embed pictures into an HTML page and make them look as if they’re loaded from some external resource. However, since the photos are stored internally, the browser wouldn’t have to make any additional HTTP requests to load the images.

Apparently, the data URI scheme accepts volume in Base64 encoded and percent-encoded. But, if you want to embed binary data into a text document, you must encode it first to Base64. Below-mentioned is the syntax for it:

data:;base64,

Here:

  • is the original data’s media type

For instance, by using the Base64 image encoder, you can make the one-pixel red dot GIF into:

data:image/gif;base64,R0lGODdhAQABAPAAAP8AAAAAACwAAAAAAQABAAACAkQBADs

And then, you can use the above-mentioned string as src of the tag:

Or, as the background-image CSS property value: 

background-image:url(“data:image/gif;base64,R0lGODdhAQABAPAAAP8AAAAAACwAAAAAAQABAAACAkQBADs”)

Moreover, you can use the data URI string in the form of a regular URL. Simply paste the same into the address bar of the browser and hit enter. You’ll get to see a one-pixel red dot picture. 

By using Base64 encoded data URIs, you can gain the following advantages:

  • It speeds up the loading of pages as the browser won’t be restricted by the maximum number of consistent HTTP requests.
  • It decreases the server load as the browser will only be making one HTTP request. This way, the server can serve more clients.
  • It offers simple hotlinking protection as nobody can embed pictures onto their pages from your server
  • It makes pages independent of external files, thus, letting you share them easily offline.
  • It enhances the overall website performance as well.

Practically, you can make use of data URIs in any manner. However, this shouldn’t motivate you to go for it all the time. Sure, it depends upon your requirements. However, jotted down below are some examples of when you can use this method:

  • When the binary file is too small (for instance, a 1×1 picture)
  • If the image is used on all the pages (for example, as a background picture)
  • Use SVG Icons

Commonly, product images are the heaviest elements on any eCommerce site, especially if it’s Magento we’re talking about. But these images aren’t the only visuals on a site. Additionally, there are a lot of simple and small images, such as shopping carts, thumbnails, stars, and more. And they have to be optimized as well. 

  • Integrate Scalable Vector Graphics (SVGs)

Vector graphics aren’t pausing from acquiring popularity in the arena of web development anytime soon. Presently, SVG has become the new preferable standard for animations and web icons. It’s trending because of reliability, instant rendering, and perfect scaling, especially in comparison to icon fonts. Considering that vector graphics are developed entirely of code, you don’t have to import them from huge external files. They’re also small in size when compared to regular PNG or JPG and most of the icon font libraries. 

  • Generating Sprites

Before stepping into sprites, let’s have a glance at a theory. Every page on a website comprises multiple elements, such as lists, paragraphs, titles, images, and more. Every element is a file. When a visitor gets to a web page, the site sends a request to the server. This request comprises the entire list of files required to develop the page. One file represents one query to the server. The more the queries, the more the need for Magento speed optimization will be.

Sprite is one such container that combines multiple small and uncomplicated pictures, such as thumbnails, hearts, stars, and more, into a huge image. Refer to this below-mentioned image for the example:

This way, your visitor will request a single image rather than sending queries for every small element. CSS sprites are adequate if you have several small but complicated photos that cannot get replaced with icons. 

To do so, you can refer to desktop graphics editors, like Adobe Illustrator, Adobe Photoshop, Paint, and more. You can also refer to online sprite generators, such as Instant Sprite and CSS Sprites. 

  • Use Icon Fonts

Icon fonts are referred to as thumbnails, stars, hearts, and more. Since they’re lightweight and can be implemented quickly, icon fonts are popular to work around with small images. 

There is an astonishingly massive variety of ready icons available out there. Thus, finding the right one for your website will not be a challenging task for you. You can either generate icons on your own or find them on several websites available out there. If you want, you can also get these customized from professionals. 

  • Use the Blur Up Technique to Load a Lower Quality Image First

Loading larger images by initially displaying the blurred versions is becoming a common concept. And, it’s considerable as well. After all, rather than watching an empty space of solid colors, your visitors get to see a blurred image before the full-image loads in.

Typically, all the modern forms of qualitative image optimization use some type of blur technique. The notion behind this is simple. You’ll have to develop a small version of the image, which is so tiny that it loads quickly. And then, you’ll have to stretch this image to the original size, so it appears blurry. Then, the full-sized picture’s loading is deferred. 

Sounds simple, isn’t it? While this idea seems quite attractive and straightforward, you’ll have to invest more time and effort into finding the right way to do so if you’re new to website development. 

The easy way is:

  • Save two copies of the image and make one of them extremely small (approximately 5×5 pixels or 1×1 pixels)
  • Use the HTML tag
  • Put an tag inside the tag where the src will be the low-quality image
  • Post this low-quality image; you can use a tag with a higher quality image

And that’s it! Now, the low-quality image will load first, and then, once it’s ready, the high-quality image will come up.

Let’s begin with the HTML file:

  

    

  

The tiny picture here is going to be set as the background picture for the . The full-sized picture will be the background picture of

. The data-src comprises a way to the full-sized image, which will be vital later on. 

Now, you have to create a small version of the picture. You’ll also have to set up the animation to fade-in the original picture:

.blur-image {

  background-image: url(data:image/jpeg;base64,…);

  filter: none;

  transition: -webkit-filter 0s 0.3s linear, filter 0s 0.3s linear;

}

.image-loaded {

  transition: opacity .25s linear;

}

.header-section, .full-image, .image-loaded {

  background-position: center center;

  background-repeat: no-repeat;

  -webkit-background-size: cover;

  -moz-background-size: cover;

  background-size: cover;

  -o-background-size: cover;

  -webkit-filter: none;

}

It’s vital to set up the background-size to cover to stretch the small image across the whole space. 

Lastly, the following will be adding class image-loaded and style=”backgroundimage:…” to

after the DOMContentLoaded event:

var a = document.querySelector(‘.blur-image’);

document.addEventListener(“DOMContentLoaded”, function() {

  if (!a) return !1;

  var b = a.getAttribute(“data-src”),

      c = document.querySelector(‘.full-image’),

      img = new Image;

  img.src = b;

  img.onload = function () {

    c.classList.add(‘image-loaded’),

    c.style.backgroundImage = ‘url(‘ + b + ‘)’;

  };

});

  • Optimize Your Image Alt Attributes

Alt attributes, also known as alt tags, are the text alternative for a picture. It’s just the text description of what exactly is happening or showcased in the image. While there has been a lot of talk around the digital world regarding alt tags, not many business owners take this aspect seriously. This is the reason why you can easily find an eCommerce store with no defined alt attributes on the images.

Alt attributes are a vital Magento SEO setting that can help boost the page’s rank. Along with that, it also helps those with eye impairments to comprehend the context of the image.

One of the good things here is that even search engines consider alt tags. If you’ve added keywords that are relevant to the page’s content in the alt attribute, web crawlers will find your page to be more relevant and index the image adequately. 

Additionally, an alt tag is also an efficient relevance signal for this search engine that assists it in structuring the search engine results page accurately and as per the search query. 

Despite that, one thing to keep in mind is that alt text isn’t created to stuff keywords. So, make sure you apply some logic and common sense when describing an image. Be on-point, concise, and specific about what exactly the picture is depicting.

Also, avoid writing too long sentences. For instance, suppose you’ve uploaded the image of an HP laptop. Instead of writing “On this image, you can see an HP laptop”, you can simply write “HP laptop.” You can also write the exact name of the product to make it more discoverable. 

Take this example for better understanding:

  • Use Image Sitemaps

The use of a sitemap increases the chances of your images getting discovered in the image search results. To provide Google with more information about the pictures that you’re using, you can run Google image extensions for these sitemaps. 

The sitemap information assists Google in indicating images on the site that you want this search engine to crawl as well as an index. Of course, web crawlers cannot crawl pictures that haven’t been called out in the webpage source code. Thus, to allow crawlers to get to know the unidentified images, list down their location in an image sitemap.

Technically, it’s a bit difficult to evaluate the effect of SEO on image optimization. But you must keep in mind that Google puts pages with SEO-optimized pictures higher than the ones with non-optimized pictures. 

Although there is a variety of methods to optimize pictures for Magento, it’s essential to discover the correct solution that is specifically for your situation. 

  • Beware of Decorative Images

The objective of an eCommerce store is to attract buyers to products and give them a brief understanding of the stock through photography. Online shoppers have to see products from every side, evaluate each detail, and comprehend every function before moving ahead with the purchase. Thus, displaying products on 3D renders or photos in full splendor is vital.

For this, you must stay away from decorative, fancy images as much as possible. Present your products in the best possible light. With eCommerce photography, your purpose should be clear: to display products in their full glory and sell them. To accomplish this objective, you must ensure that the commodity is the hero of every shot. 

Fussy backgrounds and too bright décor elements can easily distract visitors from the primary product. Thus, it’s recommended that you choose a neutral and simple background for your products. It could be simply white, in a plain bright color, or in pastel shades. 

This approach has been proven effective enough the fact that it has been used by some of the best sellers in the eCommerce industry. In fact, Amazon, the largest online selling platform across the world, requires brands to submit product photographs with white background. 

Being a marketer, you can acquire such imagery in a variety of ways. You can have the products shot on white or on specific backgrounds and have them removed through special photo editing tools. Another convenient and effective method is to go with 3D renderings so that the entire process of developing images takes place on a computer. 

While at it, make sure you don’t display a lot of bright décor elements in the pictures. This is specifically essential for small products, such as jewelry. Unnecessary props in images can divert the attention of shoppers from the main items. 

Hire Magento 2 / Adobe Commerce Experts

Sure, you have a gamut of options in front of you when it comes to optimizing your images for Magento 2. However, if you think you wouldn’t have enough time in hand to do it on your own, or you aren’t an expert in optimizing Magento 2 images adequately, you can seek professional help. 

Get in touch with HumCommerce – a platform that has mastered a variety of Magento services. Experts in the Adobe Commerce and Magento industry are running this platform to provide you with nothing but exceptional services.

Here’s what you can expect from them:

  • Performance audit & optimization
  • Magento migration services
  • Theme development
  • Extension development
  • UI/UX design
  • Customization services
  • eCommerce consulting
  • Magento SEO services
  • Integration services
  • Magento support & maintenance
  • Testing 
  • eCommerce PWA development

So, if you’re ready to get your Magento 2 images optimized, get in touch with HumCommerce right away. 

Wrapping Up

Undoubtedly, images on an eCommerce store hold utmost integrity and importance, irrespective of the platform it’s been developed on. If you’ve managed to optimize them well enough, you can significantly experience a boost in the overall performance. If not, the entire website will start lagging, and your customers may not experience the best results from their navigation. 

So, without further ado, begin by implementing these tips to optimize images on an eCommerce store today. Once done, you can track the analytics by using Google PageInsights to comprehend the difference.

Your next move should be to integrate these above-mentioned image optimization strategies and enhance the website performance pointedly. 

The post How To Optimize Your Images For Magento 2 appeared first on HumCommerce.



This post first appeared on Magento 2 Ecommerce, please read the originial post: here

Share the post

How To Optimize Your Images For Magento 2

×

Subscribe to Magento 2 Ecommerce

Get updates delivered right to your inbox!

Thank you for your subscription

×