Skip to content

RESOURCES / BLOG

What to Do When Your Web Site is Slow as Molasses in January

Web performance is one of those topics that simmers on the back burner for some developers, something that, unless well-regulated and occasionally stirred (read: fine-tuned) can easily boil over. It’s a well-worn mantra that for each second of wait time experienced by a user, revenue is lost. Bounce rates, e.g. how quickly a user will leave your site, increases 32% as a page’s load time increases from one second to three seconds. Given today’s attention spans, it’s likely that users’ patience is becoming ever shorter.

Fixing your website’s performance is not a one-time activity. As it grows and changes, performance should always be top of mind for the careful developer. Nor is a slow website repaired by focusing on just one aspect. Slow web speed can be caused by, in general, three elements:  heavy design, clunky server infrastructure, or a user’s slow internet connection. These factors can be broadly categorized into issues with the website itself (unoptimized code, huge images, video), server performance, and network conditions. Let’s focus on the first of those problems.

The use of giant images is often a culprit in site slow-downs. Even if you’re not a specialist in making your sites blazingly fast, there are a few helpers that can at the very least reduce your image load time to a reasonable level. In this article, I’d like to show how I used a tool developed by Cloudinary to measurably speed up an image-heavy site I built – not that my site will ever generate revenue, but the process became a test of how to balance image quality with site speed.

Consider this site: https://tussie-mussies.netlify.app/ which I built using Astro, with a way to pick flowers and build custom bouquets reflecting the Victorian language of flowers. It looks like this:

Tussie Mussie Generator with options for different flowers to add to your digital bouquet.

Once you choose the flowers you like, Gemini AI is used to create virtual “tussie mussies,” a favorite parlor game in the Victorian era, sending coded messages to enemies and admirers alike. In our case, you can send your AI-generated “bouquAI” via an e-card powered by Mailgun. Here’s an example of a generated bouquet:

A generated bouquet with the headline "Bouquet Meaning." Underneath, the text: Beware, dark thoughts. Alas for my poor heart, my heart aches. Refusal. Patience in adversity. Underneath it is a bouquet with the selected flowers, and Back and Download buttons.

Pretty? Yes! Useful? Well, not so much. Monetizable? Hardly! And fast? Given that there are 118 high-resolution images in the flower database, which I originally downloaded as Creative-Commons licensed flower images and stored locally, not at all!

Can we speed up this site a little simply by using Cloudinary’s image CDN and some optimizations suggested as best practices? As it turns out, there’s a useful tool that we can use to get a baseline, and then progressively optimize. It’s called Web Speed Test and is a great way to work through your image optimization challenges.

I first started by analyzing the page speed without any optimizations, and was unpleasantly surprised to discover that the images I used were heavy as heck – while pagination stops the bulk of them from loading all at once, the six plus the logo that show on the home page totaled almost 3 megabytes. Helpfully, the Web Speed Test tool offers hints on how to better follow best practices on image load: smart compression, alongside the use of Cloudinary’s CDN, should make a difference!

Image Analysis Results

Page Image Score: C
Total Images Analyzed: 7
Current Images: 2.9MB Potential after Smart Compression: 41.2KB
Total Image Weight: 3M
Potential Weight Reduction: 98.6%

I uploaded all 100+ flower images used by this site up to Cloudinary’s Assets area, keeping their original names so as to continue to be callable using the JSON file in my codebase that retains the image names and the flower’s meaning. Then, focusing on the images loaded into the image cards on the homepage, I changed the image’s url to reflect their new residence in the CDN:

<img

              :src="`https://res.cloudinary.com/${cloudName}/image/upload/flowers/${flower.image}`"

                 :alt="flower.name"

                 class="w-full h-full object-cover"

               />


Code language: JavaScript (javascript)
Note:

For those new to this domain, a CDN (Content Delivery Network) is “a geographically distributed group of servers that caches content close to end users. A CDN allows for the quick transfer of assets needed for loading Internet content, including HTML pages, JavaScript files, stylesheets, images, and videos.” according to Cloudflare. Assets geographically closer to users are delivered more quickly to their browser.

Then, it was time to try some of Cloudinary’s image transformations to optimize the delivery. Adding an f_auto parameter allows my images to be delivered in the fastest way to a given client. A scorecard offered by the Web Speed Test tool shows the potential for speeding up delivery given different image formats:

A JPEG of an anemone flower with image format options with file size and percent compared to current. WEBP has an icon of a trophy next to it.

JPEG is currently 1.4MB. There is a potential smart compression of 99.7%, from 1539x2052 to 144x192.

Following best practices to enable image compression, I then started tweaking the q_auto parameter via the URL to see how I could improve my page score. I found that by using a width setting for my responsive cards and adding q_auto:eco, I was able to compress the images to a reasonable size. By changing the :eco parameter to other options such as :good or :best you can fiddle with the amount of image loss that you can tolerate (the site has to be fast and look good, after all).

<img

       :src="`https://res.cloudinary.com/${cloudName}/image/upload/w_250/f_auto,q_auto:eco/flowers/${flower.image}`"

       :alt="flower.name"

       class="w-full h-full object-cover"

     />Code language: JavaScript (javascript)

I experimented a bit with how the images looked using q_auto (which is the same as q_auto:good) by trying best and eco settings. There’s a clear tradeoff on image quality and page load times, so use your best judgement on what is an acceptable quality level for your images for your use case. The Cloudinary docs offer a good example of how images look when this parameter changes.

By doing this tweak, I managed to get a better score – from C to B:

Image Analysis Results

Page Image Score: B
Total Images Analyzed: 7
Image Weight Comparison
Current Images: 153.1KB
Potential after Smart Compression: 33.8KB
Total Image Weight: 153K
Potential Weight Reduction: 77.9%

Mediocre to Good isn’t bad! And I get a 100% score on Lighthouse:

Performance score on Lighthouse is 100.

What other things could I do to speed the image load even more? One thing would be to create a more complex responsive design that would deliver only the smallest images to the smallest screens. Another would be to make sure that all images are meticulously cropped and resized. For the time being, however, I’m satisfied with having sped up my site a bit. 

Stay tuned for esoteric demos and sign up to enjoy the generous free tier of this top-notch image and video platform!

Start Using Cloudinary

Sign up for our free plan and start creating stunning visual experiences in minutes.

Sign Up for Free