Skip to content

Instantly share code, notes, and snippets.

@andydavies
Created December 18, 2020 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andydavies/63fc2456c0f5be0c201845eabfdf3c96 to your computer and use it in GitHub Desktop.
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
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