r/javascript • u/ds-gn • Nov 03 '26
Our JavaScript hero entrance kept LCP at ~50ms but visibly flashed. Hiding it until scripts loaded pushed LCP to ~1.75s
https://ds-gn.com/blog/javascript-motion-above-the-fold?utm_source=reddit&utm_medium=social&utm_campaign=motion_case_study&utm_content=r_javascript
8
Upvotes
9
u/JeanMeche Nov 03 '26
In my experience we shouldn't trust LCP blindly. What matters is the visual result and the user experience not the metric itself.
Like every metric, it has its caveats. This was also implicitly confirmed by some of the folks working on lighthouse.
3
u/267aa37673a9fa659490 Nov 03 '26
I just skim the article but one of my reliable way for dealing with LCP shenanigans is to use PerformanceObserver, listen for the paint event, make sure LCP is also FCP, then start loading deferred stuff only after the event fired.
2
u/ferrybig Nov 03 '26
You state that an opacity of 0 causes lcp to ignore it.
Is it only 0 and can you work around it by using 0.01 opacity, or is the threshold higher?
1
u/CobaltPhantom22 Nov 04 '26
That's a pretty significant difference. A hero animation shouldn't come at the cost of nearly 1.7 seconds of LCP. Hiding it until scripts load sounds like a sensible trade-off
1
u/baronoffeces 25d ago
That and $3 will get you a cup of coffee
1
u/gianluca_caruso-6 1d ago
Could the initial CSS show the hero in its final state and skip the entrance animation on first load? That keeps the LCP element visible without flashing through a transitional state.
0
u/[deleted] Nov 03 '26
[deleted] — view deleted comment