GSAP Motion
GSAP Preloader Optimization Without Wrecking LCP
GSAP preloader optimization is the practice of removing anything that makes a loader longer or heavier than the content it hides. In my WordPress and GSAP builds it means never imposing an artificial minimum display time, avoiding full-screen blur filters, killing infinite loops on load, and letting the real LCP element render and measure immediately.
Why a preloader hurts LCP before it helps perceived speed
A preloader does not make a page load faster; it only changes what the visitor sees while the page loads. Largest Contentful Paint is measured from navigation start to the first paint of the largest visible content element. If a full-screen overlay covers that element until a timer expires, the real LCP candidate cannot paint, so the metric records the late reveal instead. The overlay CSS, JavaScript and font requests also compete with critical resources on the same connection. I treat a preloader as a thin progress surface over already-renderable content, not as a gate that holds the hero hostage. Remove the gate and the browser can paint the hero immediately while the loader fades on top of it.
The artificial minimum display time trap
Almost every slow preloader I inherit contains the same pattern: start loading, then await a fixed delay such as 1500ms so the animation can "finish" before the site appears. That artificial minimum display time directly adds to LCP because the overlay is dismissed only after the slowest of the two promises resolves. On a fast connection the page is ready in 300ms but the visitor waits 1500ms anyway. The fix is to remove the floor entirely and tie dismissal to real readiness signals: DOMContentLoaded, the hero image load event, or document.fonts.ready. If a brand reveal is unavoidable, cap it at 200-300ms and start it only after content is ready.
- Replace fixed 1200-2000ms delays with real readiness events
- Dismiss on document.fonts.ready plus the hero image load event
- If a minimum is unavoidable, cap it at 200-300ms
- Kill the overlay timeline on completion; never leave it ticking
Blur filters and backdrop-filter: the hidden GPU cost
A full-screen backdrop-filter: blur(12px) over animated content is one of the most expensive things you can put in a critical path. Each frame forces the compositor to sample and blur everything behind the overlay, and on mid-range Android hardware that work competes with layout and paint for the main thread and GPU. When the content underneath is also animating, the browser re-blurs every frame. The result is jank that visitors read as slowness even when the network is fast. I replace the blur with a flat semi-opaque background, or a small static blurred image exported once, and reserve live blur for after the page has settled.
- Avoid backdrop-filter over moving or animating layers
- Use a solid or gradient overlay instead of live blur
- Pre-export a static blurred backdrop as an image if needed
- Apply blur only after LCP, never during initial paint
Infinite loops and a busy main thread
An infinite GSAP timeline using repeat: -1 that spins a logo or pulses a bar keeps the main thread busy for as long as it lives. If the loader timeline also reads layout inside onUpdate — offsetWidth or getBoundingClientRect — each tick forces a synchronous reflow. That subtracts from Interaction to Next Paint and drains battery on mobile. The fix is discipline: animate transform and opacity only, avoid layout-reading callbacks, and explicitly call kill() or pause() the moment the overlay is dismissed so it stops consuming frames. A loader that keeps animating after it is visually gone is a common bug I find in inherited builds.
- Use repeat: -1 only while the loader is actually visible
- Animate transform and opacity, not width or layout properties
- Never read layout in onUpdate callbacks
- Call timeline.kill() on dismissal and remove the overlay node
Structure the loader so LCP can be measured early
The cleanest structure is a small overlay that sits above content the browser can already paint. Render the hero in the normal document flow, mark it as the LCP candidate, and place the loader as a separate absolutely positioned element with a high z-index. When ready, fade it with GSAP and remove it from the DOM. Because the hero was never hidden, LCP is recorded early. A pattern I use: gsap.to(loader, { opacity: 0, duration: 0.25, onComplete: () => loader.remove() }) fired from a real readiness event, with prefers-reduced-motion skipping the tween entirely.
- Keep hero content in normal flow and never hide it with the loader
- Overlay with position: fixed and a high z-index
- Fade then remove the node on a real readiness event
- Respect prefers-reduced-motion by skipping the animation
Perceived speed tactics that do not cost LCP
Perceived speed is about feedback, not delay. A slim progress bar tied to actual asset events — xhr.load, Image.onload, document.fonts.ready — tells the visitor something is happening without inventing wait time. Skeleton screens that match the final layout give a sense of structure and avoid layout shift when content swaps in. Render meaningful HTML on the server so there is text to paint before JavaScript hydrates. Keep the loader small: a few kilobytes of CSS and one inline SVG beats a 200KB animation bundle. Done well, the loader disappears almost before it registers, and LCP reflects the real hero rather than a manufactured reveal.
How I verify it in a WordPress and GSAP build
In my WordPress and GSAP builds at webdev-saif.com I verify preloader work with both lab and field data. In the lab I run Lighthouse and WebPageTest on a throttled 4G profile with a mid-range CPU, then inspect the LCP element in the trace to confirm it is the hero, not a late overlay reveal. In the field I watch the Core Web Vitals report for LCP and INP regressions. I also check that prefers-reduced-motion users see no spinner and that the loader node is gone from the DOM after dismissal. A preloader should measure as invisible to LCP; if it shows up as the LCP element itself, it is doing harm.
Frequently asked questions
Does a preloader increase LCP?
Yes, when it hides or delays the real content. LCP is recorded when the largest visible element paints. If a loader covers the hero until a timer finishes, the metric captures that late reveal. A well-built loader sits over content that is already painted and fades quickly, so it adds almost nothing to LCP.
What is an artificial minimum display time and why avoid it?
It is a fixed floor, often 1200-2000ms, that keeps a loader on screen even after the page is ready. It directly adds dead time to LCP and frustrates visitors on fast connections. Tie dismissal to real readiness events such as document.fonts.ready and the hero image load event instead of a timer.
Is backdrop-filter blur bad for performance?
Live blur is expensive, especially over animating content, because every frame re-samples the layers behind it. On mid-range devices that work delays paint and adds jank. Use a flat or gradient overlay, or a pre-rendered blurred image, and reserve live blur for after the page has settled.
Should I use repeat: -1 on my loader animation?
Only while the loader is on screen. An infinite GSAP timeline keeps consuming frames, which hurts INP and battery life. Avoid layout reads in onUpdate, animate transform and opacity, and call kill() as soon as you dismiss the overlay so it stops ticking.
How do I make a GSAP preloader respect reduced motion?
Check window.matchMedia('(prefers-reduced-motion: reduce)').matches and, when true, skip the tween entirely: hide the overlay immediately with a class or inline style. Visitors who request reduced motion should get an instant reveal, not a fade. That is an accessibility win and a small LCP improvement.