Put this into practice
Run A/B tests and personalize your store without code. 14-day free trial, no credit card.
Start free trial →Run A/B tests and personalize your store without code. 14-day free trial, no credit card.
Start free trial →An anti-flicker snippet is a small block of synchronous JavaScript placed in the <head> of a webpage that temporarily hides the page content (typically by setting body { opacity: 0 } or display: none) until the A/B testing tool has determined which variant to show and applied it. Once the variant is ready, the snippet restores visibility — the user never sees the original content flash before the variation takes effect. It is the standard client-side fix for the flicker effect in A/B testing.
Without an anti-flicker snippet, client-side A/B tests expose a jarring user experience where content visibly changes in front of the visitor — headlines swap, images pop, buttons recolour. For ecommerce brands, this breaks trust and can increase bounce rate on tested pages.
The snippet solves the UX problem but introduces a page speed cost: the browser must wait for the testing JavaScript to load and execute before showing any content. On a fast connection, this delay is 50–150ms. On slower connections or budget Android devices common among Indian online shoppers, it can stretch to 300–600ms — adding measurably to Largest Contentful Paint (LCP) and affecting Core Web Vitals scores.
This is why the anti-flicker snippet is a temporary engineering compromise, not a permanent solution. It is appropriate for early-stage testing programs but should be replaced by server-side rendering experiments as testing matures and traffic volumes grow.
A D2C supplement brand running on Shopify (similar to WOW Skin Science) adds Google Optimize to test new hero section copy. After launch, their PageSpeed Insights score drops from 72 to 61. Investigation reveals the anti-flicker snippet adds a 420ms content-blocking delay — visible in the Waterfall chart as a dead period before LCP. Their solution: set the snippet timeout to 2000ms (the built-in kill switch that reveals the page even if the testing tool fails to respond), reduce the testing library payload by removing unused features, and restrict the experiment to desktop traffic where the delay is less severe. These changes bring LCP back within acceptable range without eliminating the experiment.
The anti-flicker snippet is specifically a client-side A/B testing infrastructure component. It is injected by testing platforms like Google Optimize (deprecated), VWO, Optimizely, or CustomFit.ai when running experiments that modify page elements via JavaScript. The snippet code typically looks like:
<style>.async-hide { opacity: 0 !important } </style>
<script>(function(a,s,y,n,c,h,i,d,e){...})(window,..., 2000, true);</script>
The integer (2000) is the timeout in milliseconds. Tuning this value is the single most impactful optimization you can make to the snippet's performance impact.
Run smarter A/B tests with CustomFit.ai — 14-day free trial, no credit card required.