Skip to content

Instantly share code, notes, and snippets.

@lesutton
Created April 14, 2022 18:40
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 lesutton/44ffedad45474ace3c13f54d4e375b8e to your computer and use it in GitHub Desktop.
Save lesutton/44ffedad45474ace3c13f54d4e375b8e to your computer and use it in GitHub Desktop.
Pre-hiding snippet for Adobe Target with asynchronous tags deployment
<script>
//prehiding snippet for Adobe Target with asynchronous tags deployment
;(function(win, doc, style, timeout) {
var STYLE_ID = 'at-body-style';
function getParent() {
return doc.getElementsByTagName('head')[0];
}
function addStyle(parent, id, def) {
if (!parent) {
return;
}
var style = doc.createElement('style');
style.id = id;
style.innerHTML = def;
parent.appendChild(style);
}
function removeStyle(parent, id) {
if (!parent) {
return;
}
var style = doc.getElementById(id);
if (!style) {
return;
}
parent.removeChild(style);
}
addStyle(getParent(), STYLE_ID, style);
setTimeout(function() {
removeStyle(getParent(), STYLE_ID);
}, timeout);
}(window, document, "body {opacity: 0 !important}", 3000));
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment