Optimisation des performances Shopify

VérifiéPrudence

Optimisez les performances Shopify — rendu Liquid, optimisation des actifs, stratégies CDN, Core Web Vitals, mise en cache Hydrogen, optimisation des images, préchargement et chargement différé.

Spar Skills Guide Bot
DeveloppementIntermédiaire
25/07/2026
Claude CodeCursorWindsurf
#shopify#performance#liquid#core-web-vitals#image-optimization

Recommandé pour

Synthèse automatique

Optimise les performances d'une boutique Shopify : rendu Liquid, poids des assets, images via le CDN, Core Web Vitals et caching Hydrogen.

Points forts

  • Tableau des anti-patterns Liquid (boucles imbriquées, all_products en boucle, include vs render) avec l'alternative recommandée pour chacun.
  • Extraits Liquid prêts à copier pour le srcset responsive, loading="lazy" et fetchpriority="high" sur l'image LCP.
  • Impose une recherche de la documentation Shopify et web.dev à jour avant d'écrire du code, ce qui limite les API obsolètes.
  • Traite à la fois les thèmes classiques (Liquid) et les storefronts Hydrogen.

Limites

  • Le corps du skill s'interrompt au LCP : les sections Hydrogen, preloading et stratégies CDN annoncées dans la description ne sont pas détaillées.
  • Aucune procédure de mesure ou de vérification (Lighthouse, Theme Speed Report) pour valider le gain avant/après.
  • Ne couvre pas les scripts injectés par les apps tierces ni les contraintes liées au plan Shopify.
Quand l'utiliser

Quand une boutique Shopify est lente et qu'il faut réduire le poids Liquid/JS ou améliorer le LCP et le CLS.

Quand l'éviter

Quand le goulot d'étranglement vient d'applications tierces ou du checkout, hors du contrôle du thème, ou s'il ne s'agit pas de Shopify.

Analyse de sécurité

Prudence
Score qualité84/100

The skill grants powerful tooling (Bash, Write, Edit, network fetch) but all instructions point to legitimate performance work: fetching Shopify/web.dev docs and editing theme or Hydrogen files. There is no obfuscation, no curl|sh piping, no rm -rf, no attempts to move secrets off-box, and no instruction to disable safety controls. The write/edit/bash access on a live storefront theme still warrants caution because changes could break a production theme, but the risk is ordinary and appropriate to the task.

Points d'attention
  • •Declares Bash, Write, and Edit tools, which can modify theme files and execute local commands
  • •WebSearch/WebFetch allow outbound network requests, though only for documentation lookups
  • •No credential handling, secret access, or destructive command patterns present
Comment cette analyse est faite

Exemples

Optimize the LCP image
My Shopify homepage hero image is the LCP element and takes 3.8s to appear. Show me the Liquid I need to preload it with fetchpriority and a responsive srcset.
Clean up a slow Liquid template
Here is my collection.liquid template with a nested loop calling all_products[handle]. Rewrite it to remove the O(n²) rendering and switch {% include %} to {% render %}.
Core Web Vitals plan
Review my Shopify theme and propose a plan to improve Core Web Vitals: inline critical CSS, defer non-critical JS, and lazy-load below-the-fold images.

name: shopify-performance description: Optimize Shopify performance — Liquid rendering, asset optimization, CDN strategies, Core Web Vitals, Hydrogen caching, image optimization, preloading, and lazy loading. Use when improving Shopify store speed. allowed-tools: Read, Write, Edit, Bash, Grep, Glob, WebSearch, WebFetch

Shopify Performance Optimization

Before writing code

Fetch live docs:

  1. Web-search site:shopify.dev theme performance for theme optimization
  2. Web-search site:shopify.dev hydrogen caching for Hydrogen caching strategies
  3. Web-search site:web.dev core web vitals for current CWV guidelines and thresholds
  4. Web-search site:shopify.dev image optimization cdn for image URL transforms
  5. Web-search site:shopify.dev theme speed report for Shopify's built-in speed metrics

Liquid Rendering Performance

Template Optimization

  • Minimize Liquid logic — complex loops and conditionals slow server-side rendering
  • Use {% render %} (not {% include %}) — isolated scope prevents variable conflicts
  • Avoid nested loops — O(n²) in Liquid is expensive
  • Limit forloop iterations with limit: parameter
  • Pre-compute values with {% assign %} instead of repeating expressions

Object Access

  • Access specific properties: {{ product.title }} not {{ product | json }}
  • Avoid all_products[handle] in loops — each is a separate data lookup
  • Use section settings to pass data instead of global lookups
  • Minimize use of {{ content_for_header }} scripts (managed by Shopify — cannot remove, but minimize additional scripts)

Liquid Anti-Patterns

| Anti-Pattern | Why It's Slow | Better Approach | |-------------|--------------|-----------------| | Nested for loops | O(n²) rendering | Flatten data, use single loop | | all_products[handle] in loop | Data fetch per iteration | Pass products via section settings | | {% include %} with variables | Shared scope causes conflicts | Use {% render %} (isolated) | | Complex {% if %} chains | Evaluated every render | Simplify conditions, use {% case %} | | Unused sections in templates | Rendered even if hidden | Remove from JSON template |

Asset Optimization

CSS

  • Minimize CSS — remove unused styles
  • Use {{ 'style.css' | asset_url | stylesheet_tag }} for proper caching
  • Critical CSS: inline above-the-fold styles in <head>
  • Defer non-critical CSS: media="print" onload="this.media='all'"

JavaScript

  • Defer non-critical JS: <script defer> or dynamic import()
  • Minimize JS bundles — Shopify themes don't need frameworks for most UI
  • Use native browser APIs over jQuery
  • Load third-party scripts asynchronously (async attribute)
  • Avoid render-blocking scripts in <head>

Images

Shopify CDN image optimization:

# Responsive images with srcset
{{ image | image_url: width: 800 }}
{{ image | image_url: width: 400 }}

# Srcset pattern
<img
  srcset="{{ image | image_url: width: 400 }} 400w,
         {{ image | image_url: width: 800 }} 800w,
         {{ image | image_url: width: 1200 }} 1200w"
  sizes="(max-width: 600px) 400px, (max-width: 1000px) 800px, 1200px"
  src="{{ image | image_url: width: 800 }}"
  alt="{{ image.alt }}"
  loading="lazy"
  width="{{ image.width }}"
  height="{{ image.height }}"
>

Key image practices:

  • Use loading="lazy" for below-the-fold images
  • Use fetchpriority="high" for LCP image
  • Set explicit width and height to prevent layout shift
  • Shopify CDN automatically serves WebP/AVIF when supported
  • URL parameters: ?width=, ?height=, ?crop=, ?format=

Fetch live docs: Web-search site:shopify.dev image_url filter parameters for current CDN transform options — new parameters are added over time.

Core Web Vitals

LCP (Largest Contentful Paint)

Target: < 2.5 seconds

  • Preload hero/LCP image: <link rel="preload" as="image" href="{{ image | image_url: width: 1200 }}">
  • Use fetchpriority="high" on LCP image
  • Avoid lazy-loading above-the-fold images
  • Minimize render-blocking CSS and JS
  • Use server-side rendering (Liquid or Hydrogen SSR)

CLS (Cumulative Layout Shift)

Target: < 0.1

  • Set explicit width and height on all images and media
  • Reserve space for dynamic content (ads, embeds, lazy-loaded images)
  • Avoid inserting content above existing content after page load
  • Use aspect-ratio CSS property for responsive media containers
  • Avoid dynamically injected banners or pop-ups that shift content

INP (Interaction to Next Paint)

Target: < 200ms

  • Minimize main-thread blocking JavaScript
  • Break up long tasks with requestIdleCallback or setTimeout(fn, 0)
  • Use CSS for animations and transitions (not JS)
  • Debounce event handlers (scroll, resize, input)
  • Avoid synchronous layout thrashing (read-then-write DOM patterns)

Fetch live docs: CWV thresholds and measurement methodology evolve. Web-search site:web.dev core web vitals thresholds for current targets.

Hydrogen Caching

Cache Strategies

// Pattern: apply cache strategy to storefront query
const data = await storefront.query(QUERY, {
  cache: CacheLong(),  // products, collections
});

const cart = await storefront.query(CART_QUERY, {
  cache: CacheShort(), // dynamic data
});

| Strategy | Use For | |----------|---------| | CacheLong() | Products, collections, pages | | CacheShort() | Cart, personalized content | | CacheNone() | Customer-specific data | | CacheCustom({...}) | Fine-tuned scenarios |

Fetch live docs for exact TTL values — Hydrogen caching defaults may change across versions.

Streaming SSR

  • Use defer() in loaders for non-critical data
  • Critical data renders immediately, deferred data streams in
  • Show loading states with <Suspense> + <Await>
  • Preload routes with <Link prefetch="intent">

Shopify CDN

Shopify's global CDN:

  • Automatic for all theme assets and images
  • Cache-Control headers managed by Shopify
  • Image transformations via URL parameters
  • No manual CDN configuration needed for themes
  • Asset fingerprinting for cache busting

Measurement Tools

| Tool | What It Measures | |------|-----------------| | Shopify Theme Speed Report | Overall theme score in admin | | Google Lighthouse | CWV + performance audit | | WebPageTest | Real-world loading waterfall | | Chrome DevTools Performance | JS profiling, layout shifts | | Search Console CWV Report | Field data from real users |

Best Practices

  • Measure before optimizing — use Lighthouse, WebPageTest, Shopify's theme speed report
  • Focus on LCP image optimization first (biggest impact for most stores)
  • Lazy-load everything below the fold
  • Minimize third-party scripts (analytics, chat widgets, social embeds)
  • Use Shopify's built-in analytics over custom tracking scripts where possible
  • For Hydrogen: cache aggressively, stream non-critical data, preload routes
  • Test on real devices and slow connections (3G throttling)
  • Set explicit dimensions on all media to prevent CLS
  • Use font-display: swap for custom fonts

Fetch the Shopify performance documentation, Core Web Vitals guides, and Hydrogen caching docs for exact optimization techniques and current best practices before implementing.

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/shopify-performance-optimization-mrzxupyl/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/shopify-performance-optimization-mrzxupyl' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/shopify-performance-optimization-mrzxupyl/download' --output '.skill-downloads/shopify-performance-optimization-mrzxupyl/SKILL.md.part' && mv '.skill-downloads/shopify-performance-optimization-mrzxupyl/SKILL.md.part' '.skill-downloads/shopify-performance-optimization-mrzxupyl/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Outils déclarés par l’auteur (à vérifier dans votre agent) : Read, Write, Edit, Bash, Grep, Glob, WebSearch, WebFetch

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/shopify-performance-optimization-mrzxupyl/SKILL.md' && test -s '.skill-downloads/shopify-performance-optimization-mrzxupyl/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/shopify-performance' && cp -R '.skill-downloads/shopify-performance-optimization-mrzxupyl' '.claude/skills/shopify-performance'

Cursor
test -f '.skill-downloads/shopify-performance-optimization-mrzxupyl/SKILL.md' && test -s '.skill-downloads/shopify-performance-optimization-mrzxupyl/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/shopify-performance' && cp -R '.skill-downloads/shopify-performance-optimization-mrzxupyl' '.cursor/skills/shopify-performance'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/shopify-performance-optimization-mrzxupyl'

openskills read 'shopify-performance-optimization-mrzxupyl'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/shopify-performance-optimization-mrzxupyl/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires