On this page
What this issue is
A/B testing tools change your page in the browser. Without protection, visitors can briefly see the original version before the variant swaps in. That jump is called flicker.
The anti-flicker snippet is a small piece of code placed in the <head>. It adds a CSS class to the <html> element that sets opacity: 0. The page is hidden. When the testing tool finishes, it removes the class and the page appears. If the tool never answers, a timeout removes the class anyway. The well-known Google Optimize snippet used 4000 ms (4 seconds). Other tools and custom copies use similar values.
<style>.async-hide { opacity: 0 !important }</style>
<script>
(function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date;
h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')};
(a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c;
})(window,document.documentElement,'async-hide','dataLayer',4000,
{'GTM-XXXXXX':true});
</script>Why it costs you leads or sales
Visitors from ads arrive with little patience. A white page for several seconds looks like a broken site, so some leave before they see your headline or form. Slow LCP can also hurt the page experience signals that Google measures, and slow landing pages can make paid traffic less efficient.
The damage is hidden. Your site is fast on your own laptop, where the tool loads quickly. It only fails on slow mobile connections, during an outage of the testing tool, or when an ad blocker stops the script. Those are the visitors who see 4 seconds of nothing.
Example: the same page measured three ways. The hidden page cannot paint until the tool answers or the timeout ends.
- Ad clickVisitor lands on the page
- HTML and CSS loadPage is ready to show
- Page hiddenopacity 0 until tool loads or 4 s passes
- Headline and formNot seen in time
- Lead or saleVisitor may have left
The page is ready early, but it stays hidden until the timeout.
How to check if your site has it
View the page source
Open the landing page, right-click, choose View page source and search for
async-hide,opacity: 0oranti-flicker. Also search for a number like 4000 near asetTimeout.Check Google Tag Manager and your testing tool
Look in your A/B tool's settings for an 'anti-flicker' or 'page hiding' option. Some tools add it for you.
Block the testing tool
In Chrome DevTools, open the Network tab, right-click the testing script, choose Block request URL, and reload. If the page stays white for seconds, the timeout is hurting visitors.
Throttle the connection
In the Network tab choose a Slow 4G profile and reload. Watch how long the page stays blank.
Record a Performance trace
In the Performance tab, record a page load and check where LCP lands. A value close to your timeout is a strong sign.
How to fix it
Pick the first option that applies. Removing the snippet is safest when you no longer run visual tests. If you do run them, keep the snippet but cut the timeout so the worst case is short.
Delete the snippet if no test needs it
Remove the style block and script that add
async-hide. This is the right fix for leftover Google Optimize code.Lower the timeout
If you keep it, change 4000 to a value around 300-500 ms. Visitors then see the original page quickly if the tool is slow.
Hide only what the test changes
Instead of hiding the whole page, hide just the element being tested, for example
.hero-headline. The rest of the page can paint and LCP stays early.Load the testing tool early and fast
Place its script high in the
<head>, serve it from the tool's recommended CDN snippet and avoid loading it through a delayed tag.Prefer server-side or redirect tests
Tests that choose the variant before the page is sent need no hiding at all.
<style>.fg-test-hide { opacity: 0 !important }</style>
<script>
document.documentElement.classList.add('fg-test-hide');
setTimeout(function () {
document.documentElement.classList.remove('fg-test-hide');
}, 400);
</script>Find the tag
In Tags, look for a Custom HTML tag containing
async-hideor your testing tool's snippet.Edit or pause it
Lower the timeout value, or pause the tag if it is leftover code. Preview the change, then Submit and publish the container.
Locate the code
Check Appearance > Theme File Editor (header.php), any header and footer scripts plugin, and your A/B testing plugin settings.
Change the timeout
Edit the number, or delete the snippet. Clear your caching plugin and CDN cache afterwards.
Open the theme code
Go to Online Store > Themes > Edit code and open
layout/theme.liquid. Search forasync-hide.Edit and check apps
Lower the timeout or remove the snippet. Also check testing apps in Settings > Apps, as some inject their own page hiding.
Open custom code
In Site settings > Custom code, check the Head code box, and any page-level Custom code in Page settings.
Edit and publish
Change or remove the snippet, then publish the site again.
Search your templates
Search the repository for
async-hideandopacity: 0 !importantin layouts and head partials.Deploy the change
Lower the timeout or remove the code, deploy, and purge the CDN cache.
How to confirm it's fixed
- View source no longer shows a timeout above about 500 ms, or the snippet is gone
- With the testing script blocked in DevTools, the page appears almost at once
- On Slow 4G throttling, the headline and form show without a long white gap
- LCP in a fresh Lighthouse or PageSpeed Insights run is back near your pre-test level
- Your A/B tool still shows the variants, with no visible flicker you find unacceptable
Before
- Whole page hidden with opacity 0
- White screen for up to 4 s
- LCP lands at the timeout
- Visitors may leave before seeing the form
After
- Timeout of about 400 ms, or no snippet
- Page shows the original content quickly
- LCP close to normal
- Test still runs on the tested element
How to prevent it happening again
- Remove testing code when a test ends or the tool is retired
- Keep one owner for the head code and review it each quarter
- Set a maximum timeout of 500 ms in your team's testing guidelines
- Test new experiments on throttled mobile before launching
- Re-check LCP on paid landing pages after every new tool or tag is added
0.0 s
Example: the visitor clicks your ad and the page request starts
0.8 s
HTML and CSS arrive, but the snippet has set opacity 0
2.0 s
The testing script is still loading on a weak connection
4.0 s
The timeout fires and the page finally appears
0.4 s (fixed)
With a short timeout the page shows almost straight away
How FunnelGuard handles this
FunnelGuard detects this issue only partly. It checks LCP only: a robot visitor loads your funnel pages on a schedule and measures Largest Contentful Paint. If a slow testing tool and a long timeout push LCP up, that shows as a slow LCP and you get an alert with a screenshot and a likely cause.
FunnelGuard does not read your code to find the anti-flicker snippet, does not report the timeout value, and cannot tell you that the snippet is the cause of a high LCP. A fast testing tool can also hide the problem, because the delay only shows when the tool is slow or blocked.
Cover the rest by hand: search your page source for async-hide or opacity: 0, check the timeout number, and run the DevTools block-request test from the checking section above. Do this after any change to your testing tool. You can start with the Free plan (1 site, 2 journeys, daily checks, no card), and a free read-only website audit is available too.
Questions people ask
Why is my page white for 4 seconds before it shows?
A common cause is an anti-flicker snippet. It hides the page with opacity 0 until your A/B testing tool loads, and if the tool is slow, a fallback timeout of about 4 seconds ends the hiding. Check your page source for async-hide and the timeout number.
What is an anti-flicker snippet?
It is a small script in the page head that hides the page while an A/B testing tool prepares its changes. It prevents visitors seeing the original version flash before the variant. A timeout removes the hiding if the tool does not respond.
How do I reduce the anti-flicker timeout?
Find the number in the snippet, often 4000, and change it to about 300-500 milliseconds. In Google Tag Manager, edit the Custom HTML tag and publish. On other platforms, edit the theme or head code, then clear caches.
Can I just remove the anti-flicker snippet?
Yes, if you do not run visual A/B tests on that page. Without it, visitors may see a brief flicker on tested elements, but the page is never blanked. Leftover Google Optimize code should always be removed.
Does the anti-flicker snippet hurt LCP?
Yes. While the page is hidden, the browser cannot paint the main content, so LCP is pushed to when the hiding ends. A slow tool and a long timeout can add seconds.
Is Google Optimize still working?
No. Google ended Optimize in September 2023. Any remaining Optimize snippet only adds delay, so remove it and its container reference.
How do I test the anti-flicker delay myself?
Open Chrome DevTools, go to the Network tab, block the testing tool's script URL and reload the page. If the page stays white for seconds, the timeout is too long. Repeat on a Slow 4G throttle.
Can FunnelGuard detect an anti-flicker snippet?
Only partly. FunnelGuard measures LCP on your funnel pages, so a long delay can show up as a slow LCP. It does not identify the snippet or its timeout, so check the page source by hand.
Related issues
- PRF-019Above-the-fold content hidden by A/B testing anti-flicker snippetFix guide
- PRF-001LCP over 2.5 s on a funnel stepFix guide
- PRF-002LCP over 4 s on mobile (poor) on the paid landing pageFix guide
- PRF-012Render-blocking synchronous JS in <head> (jQuery, sliders)Fix guide
- PRF-016Client-side rendered page shows blank until JS bundle runsFix guide
- PRF-021Preloader / splash animation delays contentFix guide