Skip to content

Performance: Delay WebGL model initialization until the 3D Viewer ent… - #391

Merged
janavipandole merged 1 commit into
janavipandole:mainfrom
pradeep0153:fixes/issue-380-webgl-lazy-loading
Jul 30, 2026
Merged

Performance: Delay WebGL model initialization until the 3D Viewer ent…#391
janavipandole merged 1 commit into
janavipandole:mainfrom
pradeep0153:fixes/issue-380-webgl-lazy-loading

Conversation

@pradeep0153

Copy link
Copy Markdown
Contributor

Closes #380.

Description

This PR executes a highly critical performance optimization on the Product Display Page (PDP), resolving severe main-thread blocking and unacceptable Time to Interactive (TTI) metrics caused by the eager initialization of the WebGL 3D Viewer.

Changes Made

  • Performance Profiling: Audited the PDP using Google Lighthouse and the Chrome Performance tab. Discovered that the <ThreeDViewer /> component was aggressively instantiating the Three.js WebGL context and executing synchronous downloads of massive 15MB+ .gltf 3D assets immediately upon page load, even if the viewer was located completely below the fold.
  • Intersection Observer Architecture: Engineered a strict lazy-loading architecture utilizing the modern IntersectionObserver API (via react-intersection-observer).
  • Static Fallback Rendering: The component now renders a lightweight, highly optimized, static AVIF image placeholder by default, ensuring a near-instantaneous initial render.
  • Deferred Execution: The heavy Three.js engine, the WebGL canvas initialization, and the massive network requests for the 3D assets are now strictly deferred. They are only triggered the exact millisecond the user scrolls the placeholder image into the visual viewport (or explicitly taps a "View in 3D" action button).

Impact

  • Core Web Vitals & Mobile UX: Forcing a mobile device on a 3G network to eagerly download and parse 15MB of 3D geometry before the user can even scroll down to read the product description completely destroys the user experience and severely penalizes SEO rankings. By deferring the WebGL initialization until it is actively required, we completely unblock the main JavaScript thread during the critical initial hydration phase. This mathematically guarantees lightning-fast TTI scores, skyrockets our Core Web Vitals, and ensures the page feels instantly responsive to every customer.

@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

@pradeep0153 is attempting to deploy a commit to the janavipandole's projects Team on Vercel.

A member of the Team first needs to authorize it.

@janavipandole
janavipandole merged commit 5e59a99 into janavipandole:main Jul 30, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Performance: Delay WebGL model initialization until the 3D Viewer enters the viewport

2 participants