Skip to content
FunnelGuard

Fix guide by FunnelsGuard

A/B test anti-flicker snippet hiding your page: how to fix it

PRF-019High impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

A/B testing tools change your page in the browser. If the original page shows first and the variant swaps in a moment later, visitors see a jump. This is called flicker.

To hide the jump, many tools ask you to add an anti-flicker snippet. It adds a CSS class to the <html> element that sets opacity: 0, then removes it when the tool is ready or when a timeout runs out. Google Optimize used a snippet called async-hide. Other tools, such as VWO, Optimizely, AB Tasty and Convert, have their own versions.

Typical anti-flicker pattern (simplified)html
<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 decide fast. If they see a blank white page for a second or more, some leave before the form or buy button appears. You pay for that click and get nothing.

It also hurts your speed scores. A hidden hero delays LCP, which is one of Google's Core Web Vitals. Slow landing pages can lower the experience score on paid traffic and make every test run on a worse page than you think.

There is a second cost: the test itself. If the tool is slow or blocked (by an ad blocker or a network issue), the page stays hidden until the timeout. Every visitor in that situation waits for nothing.

What the visitor experiences
  1. Click on adVisitor lands on the page
  2. HTML and CSS loadHero is ready to show
  3. Snippet hides pageopacity: 0 on the html element
  4. Hero visibleOnly after the tool loads or timeout
  5. Form or buy clickSome visitors have already left

The page is built quickly, but the snippet keeps it invisible until the testing tool answers or the timeout ends.

LCP with and without the snippetExample numbers
LCP with and without the snippet (example)Snippet, tool loads fast: 2.4 seconds; Snippet, tool slow: 4.6 seconds; No snippet: 1.9 seconds0242.44.61.9Snippet, tool loads f…Snippet, tool slowNo snippetseconds

Example: illustrative numbers for one landing page on a mid-range phone. Your own values will differ.

How to check if your site has it

Find the snippet and see its effect
  1. View the page source

    Open your landing page, right-click and choose View page source. Search for async-hide, opacity:0, opacity: 0 !important, or the name of your testing tool (vwo, optimizely, abtasty, convert).

  2. Look at the html element while loading

    In Chrome DevTools, open the Network tab, set throttling to Slow 4G, reload, and watch the html element in the Elements tab. A class such as async-hide that disappears later is the snippet.

  3. Record a Performance trace

    In the Performance tab, tick Screenshots and reload. If the screenshots show a blank page while the HTML is already parsed, the page is being hidden.

  4. Check the LCP element

    In the trace, open the Timings lane and click LCP. Compare its time with when the testing script finished loading.

  5. Test with the tool blocked

    Block the testing tool's domain in DevTools (Network request blocking) and reload. If the page stays blank until a fixed timeout, you have found a slow-tool risk.

How to fix it

Pick the option that fits your setup. Option 1 is best if you do not need to hide changes. Option 2 keeps testing but limits the damage.

Options, from safest for speed to most cautious
OptionWhat you doTrade-off
Remove the snippetDelete the hide style and scriptSome visitors may see a brief flicker on test pages
Shorten the timeoutChange the timeout from 4000 ms to about 300-500 msSlow tool loads show the original page
Hide only the tested elementHide a single selector, not the whole pageNeeds a stable selector
Use server-side or edge testingChoose the variant before the page is sentNeeds developer work or a tool that supports it
Where to change it
  1. Find the snippet

    In Tags, look for a Custom HTML tag containing async-hide or your tool's hide code. Check it is not also pasted in the theme.

  2. Edit or pause it

    Lower the timeout value, or pause the tag and Preview to test. Fire it on All Pages only if you need it everywhere; limit it to pages in an active test.

  3. Publish

    Submit and publish a new container version with a clear name.

Safer pattern: hide one element, short timeouthtml
<style>.fg-hide-hero { opacity: 0 !important }</style>
<script>
(function () {
  var el = document.documentElement;
  el.className += ' fg-hide-hero';
  var done = function () { el.className = el.className.replace(/ ?fg-hide-hero/, ''); };
  setTimeout(done, 400);
  window.addEventListener('abtest-ready', done);
})();
</script>
Page behaviour

Before

  • Whole page hidden until the tool loads
  • Hero appears after a 4 s timeout if the tool is slow
  • LCP tied to a third-party script

After

  • Page visible straight away or after a very short wait
  • Only the tested element is ever hidden
  • LCP depends on your own hero image and CSS

How to confirm it's fixed

Confirmation checks
  • View source no longer shows the page-wide hide style, or the timeout is short
  • In a throttled Performance trace, the first screenshot already shows the hero
  • Blocking the testing tool's domain does not leave the page blank
  • LCP in PageSpeed Insights or Lighthouse is lower than before
  • Active A/B tests still run and variants still appear
  • The form, checkout or booking button still works on the test page

How to prevent it happening again

Habits that keep it away
  • Agree a maximum hide timeout (for example 400 ms) with whoever sets up tests
  • Remove the snippet when a test ends and the tool is no longer used
  • Keep one owner for head scripts so the snippet is not pasted in two places
  • Run a speed check on a landing page after every new test tool or major test goes live
  • Prefer server-side or edge testing for hero changes
How a slow testing tool plays out
  1. 0.0 s

    Visitor arrives, snippet hides the page

  2. 0.8 s

    Hero image and CSS are ready but invisible

  3. 2.0 s

    Testing script is still loading on a weak mobile connection

  4. 4.0 s

    Timeout ends and the page finally appears

Try the anti-flicker snippetInteractive
Anti-flicker snippet hides the whole page

Snippet on

Leads or data lost

The hero is invisible until the testing tool loads or the timeout ends. LCP is late and some visitors leave.

Example only: toggle the snippet to see how it changes what the visitor sees.

How FunnelGuard handles this

FunnelGuard detects this issue only partly. A robot visitor runs your real journey on a schedule and can see when a page is slow to show its main content, so an LCP delay on a funnel step is something it can pick up. It does not identify the anti-flicker snippet itself, so an alert will not say "your A/B testing snippet is hiding the page".

To cover the rest by hand, use the checks above: search the page source for the hide style, record a throttled Performance trace, and block the testing tool's domain to see whether the page stays blank. Do this whenever FunnelGuard reports a slow step on a page that runs A/B tests, and after you add or change a test.

FunnelGuard's Free plan covers 1 site and 2 journeys with daily checks and no card. Paid plans start at $39/month with a 3-day free trial.

Questions people ask

What is an anti-flicker snippet?

It is a small piece of code that makes the page invisible (usually with opacity: 0) until your A/B testing tool has applied its changes. It stops visitors seeing the original version jump into the variant. The cost is that the page stays hidden while the tool loads.

Why is my page blank for a few seconds before it shows?

If you run A/B tests, an anti-flicker snippet may be hiding the page until the testing script loads or a timeout of around 4 seconds ends. Check the page source for async-hide or opacity: 0 on the html element. A slow or blocked testing tool makes the blank period longer.

Does the anti-flicker snippet hurt LCP?

Yes, it can. The hero is hidden until the snippet releases the page, so Largest Contentful Paint is delayed by the wait for the testing tool or the timeout. Removing or shortening it usually brings LCP back toward the speed of your own page.

How do I remove the anti-flicker snippet?

Find where it was added: your theme header, Google Tag Manager, a code injection setting or the testing tool's plugin. Delete the hide style and script, or lower the timeout to a few hundred milliseconds, then clear caches and re-test. Make sure running tests still work.

What timeout should I use for an anti-flicker snippet?

Keep it short, around 300 to 500 milliseconds, rather than the common 4000. A short timeout limits how long visitors can be left with a blank page if the tool is slow. The trade-off is that a slow tool may show the original page instead of the variant.

Do I still need an anti-flicker snippet after Google Optimize shut down?

No, not for Optimize. Google Optimize ended in 2023, so an old async-hide snippet tied to it does nothing useful. Remove it. If you use another testing tool, check its own documentation on whether flicker protection is needed.

Can FunnelGuard tell me if an anti-flicker snippet is slowing my page?

Only partly. FunnelGuard can show an LCP delay on a funnel step, but it does not identify the snippet as the cause. You confirm the cause by checking the page source and a throttled performance trace by hand.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: LCP delay seen; snippet not identified.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.