Skip to main content

Anti-Flicker

Without anti-flicker, visitors briefly see your original page before your A/B test variant loads. It's a 100–300ms flash that makes your experiments look broken and can skew your results.

Datsnip's anti-flicker snippet prevents this completely.


Is it already included?​

Yes — when you copy the full snippet from Settings → Install Snippet and choose the With Anti-Flicker option (the default), those 3 lines above your main script tag handle it automatically.

The snippet from your dashboard already looks like this:

<style id="_gs_af">html{visibility:hidden;pointer-events:none}</style>
<noscript><style>#_gs_af{visibility:visible!important}</style></noscript>
<script>setTimeout(function(){var e=document.getElementById('_gs_af');if(e)e.remove()},3000)</script>

<script>
(function(w,d,k){
w._sf = { siteId: k, ingestUrl: 'https://api.datsnip.com' };
var s = d.createElement('script'); s.async = 1;
s.src = 'https://api.datsnip.com/sdk/tracker.js';
d.head.appendChild(s);
})(window, document, 'YOUR_SITE_ID');
</script>

Just paste it before </head> on every page and you're done.


What it does​

  1. The page hides instantly when it starts loading
  2. Datsnip loads, figures out which variant to show, and applies it
  3. The page becomes visible — already showing the right variant

Visitors never see the original content flash before the variant appears.

The 3-second safety timeout ensures your page is always visible even if something goes wrong with the snippet loading.


Does it slow down my site?​

Barely. Datsnip loads from a global CDN and typically resolves in under 100ms. The page is hidden for that window only.

The technique also uses visibility:hidden — not display:none — which means your page layout is preserved during loading and there's no visual pop when it becomes visible. No Core Web Vitals penalty.


Do I need this if I'm not running experiments?​

No. Anti-flicker only matters for A/B tests — it hides the page until the variant is applied. If you're only using banners or triggers, the anti-flicker snippet is harmless but not necessary.