
From the conversion glossary
Concepts referenced in this article, defined.

Concepts referenced in this article, defined.
Run rigorous A/B tests and personalize every visit on Shopify or any storefront โ no engineers required.
Flicker in A/B testing is the brief flash of your original page content before a test variant loads โ it happens because browsers render HTML before JavaScript executes variant changes. To eliminate flicker, load your testing tool's anti-flicker snippet at the very top of your page's <head> tag; this briefly hides the page while variants apply, then shows the correctly styled version without any visible flash. Most reputable A/B testing tools (including CustomFit.ai) include this automatically.
When you run a client-side A/B test, here's what happens on the visitor's device:
The problem: steps 3 and 4 happen asynchronously. During the gap between initial render and JavaScript execution (typically 50โ300ms), the control version is visible. This flash of original content (sometimes called FOOC) is what testers call "flicker."
Test validity: If visitors see the control headline for 200ms before the variant headline loads, they haven't experienced a clean variant-only condition. This contamination is most impactful for above-the-fold content where the flicker is most visible.
User experience: Visible layout jumps and content switches are jarring. On a product page, a flickering hero image or CTA button can actively undermine trust โ the opposite of what your tests are meant to achieve.
Statistical bias: Flicker is worse on slower devices and connections. If your mobile visitors (typically on slower networks) see more flicker than desktop visitors, your test results could be systematically biased by device type.
The anti-flicker snippet solves the flicker problem with a controlled, brief page hide:
// Simplified anti-flicker pattern
(function() {
document.documentElement.style.opacity = '0';
window.__antiflicker = setTimeout(function() {
document.documentElement.style.opacity = '1';
}, 300); // Maximum wait time
})();When the testing tool finishes loading and applying variants, it clears the timeout and sets opacity back to 1. The visitor experiences a brief delay (imperceptible on fast connections) rather than a jarring layout flash.
Critical requirement: The anti-flicker snippet must load synchronously at the very top of <head> โ before any other scripts, stylesheets, or content. If it loads asynchronously or after other content, the flicker has already happened before the snippet executes.
For Shopify stores, the anti-flicker snippet goes in theme.liquid, at the top of the <head> section:
<head>
<!-- Anti-flicker snippet MUST be first -->
<script>
// Your testing tool's anti-flicker code here
</script>
<!-- All other head content follows -->
{{ content_for_header }}
...
</head>Important: Placing the snippet anywhere other than the very first element in <head> dramatically reduces its effectiveness. Even being second or third โ behind a CSS file or meta tag โ can allow flicker on fast-rendering browsers.
CustomFit.ai's Shopify app handles anti-flicker implementation automatically. When you install the app, it injects the optimized snippet at the correct position in your theme without manual configuration. This eliminates both flicker and the implementation risk of placing the snippet incorrectly.
Before implementing anti-flicker code, diagnose whether you actually have a flicker problem:
Method 1: Throttled browser test
Method 2: Disable caching and watch for jumps
Method 3: Check your testing tool's performance panel
Mistake 1: Loading the snippet asynchronously
<!-- WRONG: async defeats the purpose -->
<script async src="testing-tool-snippet.js"></script>
<!-- RIGHT: synchronous, inline -->
<script>
(function() { /* anti-flicker code */ })();
</script>Mistake 2: Setting the timeout too long A 3-second timeout means 3 seconds of blank page if the testing script fails to load. Keep your maximum timeout at 300โ500ms. If the script hasn't loaded in that window, show the control version immediately.
Mistake 3: Not handling script failures If your testing tool script fails to load (CDN outage, network error), the anti-flicker timeout should automatically expire and show the page. Without this safety net, visitors see a blank page indefinitely.
Mistake 4: Applying it selectively Some teams apply anti-flicker only to heavily-tested pages. This creates inconsistent behavior and still exposes some visitors to flicker. Apply it site-wide.
The nuclear option for eliminating flicker is server-side A/B testing. Since variants are rendered on the server before the HTML is sent to the browser, there's no JavaScript execution gap โ no flicker possible.
The tradeoff: server-side testing requires developer involvement and slows experimentation velocity significantly. For most D2C ecommerce brands, the anti-flicker snippet is the right tradeoff โ it eliminates visible flicker while maintaining the speed and accessibility of client-side testing.
Use server-side testing when:
Test on real devices, not just desktop Chrome. Flicker is dramatically worse on mid-range Android phones on mobile data. India's diverse device landscape means your โน6,000 Android user on a 4G connection experiences pages very differently from your desktop tester. Always validate anti-flicker implementation on representative mobile devices.
Keep your testing snippet small and fast. Every kilobyte of the anti-flicker snippet is a synchronous load delay. Minimize the snippet size and serve it from a fast CDN.
Set a reasonable timeout. 300ms is typically optimal โ long enough for the testing script to load on fast connections, short enough that slow connections see the page without excessive delay. Adjust based on your typical page load metrics.
Monitor for variant-specific performance issues. A variant that loads significantly slower than the control โ due to heavier images or more JavaScript โ creates flicker even with a proper anti-flicker snippet. Profile all variant assets.
Verify implementation after every Shopify theme update. Theme updates can inadvertently reorder head elements, potentially moving your anti-flicker snippet out of first position. Check after every major theme change.
<head> โ placement matters as much as the code itself.