Tips and resources for speed optimization focused developers.

Shopify Partner
257 31 132

Hey, so cool to see a forum focused on speed. I thought I'd start a thread to share tips and resources  on speed optimization.

I have certain ways of optimizing things, It'd be cool to see what other people use, and what I might be missing.

Bellow are some basic techniques and tools I use top optimize a page, in no particular order.

render blocking resources

for generating critical css, I tend to use web based tools, since they work fine and its way faster then downloading the site and running a tool locally.

Then my preferred way of handling the inline css is to create a snippet like


{% render 'critcal_style_controller' %}



then I'll set up the snippet like 


{% assign handle = | append: '.' | append: template.suffix %}
{% case handle %}
{% when 'index.' %}
{% when 'product.' %}
{% when 'product.awesome-version' %}
{% else %}
{% endcase %}



For making style sheets async, I use the method described in the answer in this Slack overflow post.



Most themes are good about lazyloading, and shopify already converts to webp. So usually I end up doing a few optimizations.

Sometimes themes will not have lazyloading for background images.

Usually most themes use lazysizes, so I add the UnveilHooks plugin for lazysizes

Now that page speed insights implemented its CLS metric, its important to have width and height attributes so the browser can get an image's aspect ratio and reduce content shift.

For most scenarios, something like


src="{{img | img_url: '5x'}}"
data-src=" {{img | img_url: '500x'}} "
height="{{ img.height }}"
width="{{ img.width }}"



For  background images I use the aspect ratio padding technique


I like to compress above the fold images, helps decrease time for largest contentfull paint. Since I'm usually only compressing a few images, I prefer to use a web tool as opposed to a local tool. is pretty usefull.

Optimizing css

shopify already takes care of removing unused css, but it doesn't remove duplicate selectors, duplicate rules, and empty rules.

I'm only just starting to add this step to my workflow, and still experimenting with different tools, would be cool to see what other people use, and what doesn't work with scss.liquid files that have liquid syntax.


Thats all for now, I'll update this post as I think of more things I use, or discover new stuff, very interested to see what tips other people have.

Available for pagespeed consulting
Replies 2 (2)

Not applicable

I have to respectfully disagree with your recommendation for the lazy loaded image snippet. By loading a smaller placeholder image you're effectively doubling the number of image-based requests for each image tag present on the page. On a collections page with 50 products displayed and an image-swap feature you're just adding 100 unnecessary requests - that's counter-intuitive to the concept of lazy loading. Instead using a blank data image or svg company logo would reduce this from 200 image-based requests to 100 or 101, respectively.


The Shopify Analyzer is a great tool which aims to target most theme-related speed issues (these are realistic, attainable, and easy to fix for the average Shopify store owner with a limited amount of technical knowledge and each of the categories listed have a direct impact to page speed):


Shopify mentions that their average site score is a 34 on Lighthouse - I don't know how this translates to real speed, but at Speed Boostr we had an average speed improvement of 32% among all Shopify sites that we optimized last year and we're focused on optimization specifically for Shopify sites:


We offer a lot of free resources and guides for optimization on our blog.

A complete guide to performance optimizations for Shopify:

How to apply Lazy Loading for a Shopify site:

How to compress images for a Shopify site:

How to use vector images to improve performance:

How to minimize CSS for a Shopify site:

How to find and fix console errors:

How to conditionally load apps and scripts for Shopify sites

Using resource hints to improve performance on Shopify sites:

Using AMP to improve speed + SEO for Shopify sites:

Optimizing image SEO for Shopify sites:

Optimizing conversion for Shopify sites:

Optimizing conversion through A/B Testing on Shopify:


I've optimized a few hundred sites for speed and even themes with high scores out-of-the-box can have their page speed lowered substantially by app content, so it's also worth noting that even a high-scoring theme has no chance for a fast page load time as long as a high volume of apps are present on the store (more details here: so unfortunately a great deal of optimization opportunities are at the sole discretion of app developers.

Shopify Partner
257 31 132

Oh, I didn't realize that you can only edit your post before 2 hours.

Here's another tip:

Stopping a script from being detected by PageSpeed Insights.

If your really worried about your score, this won't make much a difference user experience wise but it will help with your score.

You can use this for any script that isn't necessary for the appearance and functionality of above the fold content, great for apps that have an option for manual installation, like tidio.

    var loadScript = function() {
     var scripts = ['example-script1.js', 'example-script2.js']
     scripts.forEach( function(scriptSrc) {
     var tag = document.createElement("script");
    window.addEventListener('scroll',loadScript );


Available for pagespeed consulting