Open
Conversation
Perf: Make scroll event listeners passive
Perf: Disable slide-reveal on mobile
Perf: Defer predictive-search.js loading
St/responsive images
…yload St/predictive search lazyload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Optimizations implemented to improve the LCP (Largest Contentful Paint) and overall mobile performance of the Shopify theme.
1. Responsive Images & LCP Optimization (Phase 1)
I enhanced the image loading strategy to ensure critical assets load as fast as possible while secondary images are deferred.
Key Changes:
snippets/image.liquid:Expanded widths to include intermediate candidates (535, 750, 1070) for better DPR coverage.Implemented a robust sizes attribute calculation based on layout requirements.
Integrated fetchpriority and loading attributes directly into the image_tag.
**sections/hero.liquid & sections/_layered-slide.liquid:**Identified as potential LCP candidates.
Applied loading="eager" and fetchpriority="high" to the first image found in these sections.
layout/theme.liquid:Added a conditional preload for the first LCP image (Hero or Slideshow) to start downloading it immediately.
2. Deferred Hydration for Mobile (Phase 2)
To reduce the main thread work and improve TBT (Total Blocking Time) on mobile, I implemented a deferred hydration utility.
Key Changes:
**assets/deferred-hydration.js:**Created a custom element that uses IntersectionObserver to only render its content when it enters the viewport (or is about to, with a 200px margin).Includes a data-mobile-only attribute to ensure desktop users get the full experience immediately while mobile users benefit from lazy loading heavy sections.
Wrapping Heavy Sections:
blocks/accordion.liquid:Wrapped content to defer accordion initialization.blocks/review.liquid:Wrapped review stars to defer third-party or heavy rendering.blocks/product-recommendations.liquid:Wrapped the entire recommendations section, which is typically heavy and below the fold.