Skip to main content

Anti-flicker script

If you are experiencing "flicker" with your experiments you can implement our anti-flicker script. This will render the page white until the variation changes has been made. This has a fallback to remove the white page after five seconds if the Lyftio for any reason has not loaded by that.

Implementation

This anti-flicker script needs to be implemented first in the head tag to work as expected.

<script>
!function(e,t){const n=`.${t} { opacity: 0 !important }`,o=document.createElement("style");o.id=t,o.sheet?o.sheet.insertRule(n):o.appendChild(document.createTextNode(n)),document.head.appendChild(o),e.classList.add(t);let d=!1;const c=function(){if(!d){d=!0,e.classList.remove(t);const n=document.getElementById(t);null!=n&&n.remove()}};window.addEventListener("Lyftio::Started",c,{once:!0}),setTimeout(c,5e3)}(document.documentElement,"lioWhitepage");
</script>
note

The fallback time can be changed by altering the following in the code above; setTimeout(c,5e3)