1. Tips & Tricks
  • Getting Started
    • Introduction
    • Theme Development
    • Publishing Your Theme
    • Legacy Theme Migration
      • Store Settings Mapping
      • Moving to Vitrin Using LLMs
      • Twig to Jinja
      • Breaking Changes
  • Key Concepts
    • Architecture
    • Templates
      • Overview
      • Template Library
        • home.jinja
        • 404_not_found.jinja
        • account_wishlist.jinja
        • categories.jinja
        • page.jinja
        • reviews.jinja
        • account_addresses.jinja
        • blog.jinja
        • category.jinja
        • product.jinja
        • search.jinja
        • account_orders.jinja
        • blogs.jinja
        • faqs.jinja
        • products.jinja
        • shipping_payment.jinja
        • account_profile.jinja
        • cart.jinja
        • questions.jinja
        • wishlist.jinja
    • Settings
      • Sections
      • Input Settings
      • Media Settings
      • Form Controls Settings
      • Products Settings
      • Additional Settings
      • Conditional Visibility
      • Migrating twig settings schema
    • Localization
      • localization (jinja v. twig)
  • Building with Vitrin
    • Jinja Basics
    • Vitrin's Jinja Extensions
    • Objects Reference
  • Vitrin CLI
    • Introduction
    • CLI Commands
  • Tips & Tricks
    • Performance
  • Features
    • Loyalty
    • Bundle Products
  1. Tips & Tricks

Performance

Follow these tips to improve loading times and Core Web Vitals scores.

Preload Critical Assets#

Preloading key images can significantly improve your Core Web Vitals:
First Contentful Paint (FCP) — Preload the store logo so it appears as soon as possible.
Largest Contentful Paint (LCP) — Preload large banners or hero images to speed up main visual rendering.
Add the preload tags in your <head> section:
<link rel="preload" as="image"
      href="{{ image_url(logoUrl, h=175, q=100) }}"
      media="(min-width: 992px)">

{% if logoUrlMobile %}
  <link rel="preload" as="image"
        href="{{ image_url(logoUrlMobile, h=175, q=100) }}"
        media="(max-width: 991px)">
{% else %}
  <link rel="preload" as="image"
        href="{{ image_url(logoUrl, h=175, q=100) }}"
        media="(max-width: 991px)">
{% endif %}
The media attribute specifies the viewport size that triggers the preloading.
In the example above, we preload a different logo for desktop and mobile, with a fallback to the desktop logo if logoUrlMobile is not defined.

Optimize Script Loading#

Use async for scripts that don’t require order.
Use defer for scripts that require order but should not block rendering:

Image Optimization#

Use responsive images with srcset to serve the right size based on device:
Modified at 2025-08-19 09:01:04
Previous
CLI Commands
Next
Loyalty
Built with