Created
December 18, 2020 10:42
-
-
Save andydavies/63fc2456c0f5be0c201845eabfdf3c96 to your computer and use it in GitHub Desktop.
Uses a Mutation Observer to detect when VWO injects it's anti-flicker styles into the page and them removes them - handy for WPT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
callback = function(mutationsList, headObserver) { | |
// Use traditional 'for loops' for IE 11 | |
for(mutation of mutationsList) { | |
for(node of mutation.addedNodes) { | |
if(node.nodeName === 'STYLE' && node.id === '_vis_opt_path_hides') { | |
node.parentNode.removeChild(node); | |
performance.mark('vwo-hide-start'); | |
} | |
} | |
} | |
}; | |
headObserver = new MutationObserver(callback); | |
headNode = document.getElementsByTagName('head')[0]; | |
headObserver.observe(headNode, { childList: true }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment