This article covers essential optimizations for Shopify stores that can significantly improve performance and SEO rankings. These techniques address common issues I’ve encountered while working with Shopify themes.

When a browser encounters a script while parsing HTML, it pauses to execute the script before continuing. This delay impacts your page load time and user experience.

Solution: Use defer or async attributes on non-critical scripts:

<!-- Non-critical script with defer -->
<script src="{{ 'pickup-availability.js' | asset_url }}" defer></script>

<!-- For critical scripts that must execute immediately, don't use defer -->
<script src="{{ 'critical-functionality.js' | asset_url }}"></script>

Key difference: defer maintains execution order while async executes as soon as downloaded.

Optimize Your Images

Images often account for the largest portion of page weight. Optimize them for significant performance gains:

  • Use Squoosh or Shopify’s built-in optimization to compress images
  • Prioritize critical images with fetchPriority="high"
  • Lazy load below-the-fold images
  • Leverage Shopify’s responsive image capabilities
<!-- Critical hero image -->
<link rel="preload" as="image" href="{{ hero_image | img_url: 'large' }}">
<img fetchPriority="high" src="{{ hero_image | img_url: 'large' }}" alt="{{ hero_image.alt }}">

<!-- Non-critical product image with lazy loading -->
<img loading="lazy" src="{{ product_image | img_url: 'medium' }}" alt="{{ product_image.alt }}">

Use Semantic HTML for Better SEO

Replace generic <div> elements with semantic HTML tags to improve accessibility and help search engines understand your content:

<header>
  <nav><!-- Navigation items --></nav>
</header>
<main>
  <section class="hero"><!-- Hero content --></section>
  <article class="product-description"><!-- Product details --></article>
</main>
<footer><!-- Footer content --></footer>

Optimize Embedded Content (Iframes)

Iframes (like YouTube videos) can slow down your page considerably. Improve performance by loading them only when needed:

<div id="video-container" class="video-placeholder">
  <img
    src="https://img.youtube.com/vi/VIDEO_ID/hqdefault.jpg"
    alt="Video thumbnail"
    loading="lazy"
    class="video-thumbnail"
  />
  <div class="play-button">Play Video</div>
</div>

<script>
  document.getElementById('video-container').addEventListener('click', () => {
    const iframe = document.createElement('iframe');
    iframe.src = "https://www.youtube-nocookie.com/embed/VIDEO_ID";
    iframe.title = "YouTube video";
    iframe.allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture";
    iframe.allowFullscreen = true;
    const container = document.getElementById('video-container');
    container.innerHTML = "";
    container.appendChild(iframe);
  });
</script>

Minimize App Impact

Each app you install can add JavaScript that slows down your store:

  • Regularly audit your apps and remove unused ones
  • Choose apps that use theme app extensions rather than injected scripts
  • Consider implementing critical functionality directly in your theme

By implementing these optimizations, you can dramatically improve your Shopify store’s loading times, Core Web Vital scores, and ultimately increase conversions. Remember that mobile optimization is particularly crucial, as most Shopify traffic now comes from mobile devices.