Inject scripts into HTML responses at the edge.
Script Injection lets you add JavaScript, analytics, or other code to your HTML pages without modifying your origin. Scripts are injected at the CDN edge during delivery.
Injection happens in real-time during delivery.
Name: A descriptive name for the script.
Content: The HTML/JavaScript code to inject.
Placement:
head: Inject before </head>body: Inject before </body>Enabled: Toggle to enable/disable without deleting.
Placement: head
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXX');
</script>
Placement: head
<script>
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXX');
</script>
Placement: body
<script>
window.intercomSettings = {
api_base: "https://api-iam.intercom.io",
app_id: "xxxxxxxx"
};
</script>
<script>
(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',w.intercomSettings);}else{var d=document;var i=function(){i.c(arguments);};i.q=[];i.c=function(args){i.q.push(args);};w.Intercom=i;var l=function(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/xxxxxxxx';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);};if(document.readyState==='complete'){l();}else if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})();
</script>
Placement: body
<script src="https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.js"></script>
<script>
window.cookieconsent.initialise({
palette: {
popup: { background: "/docs/1.0/features/script-injection#1d1d1d" },
button: { background: "/docs/1.0/features/script-injection#f97316" }
},
content: {
message: "We use cookies to improve your experience.",
dismiss: "Got it!",
link: "Learn more",
href: "/privacy"
}
});
</script>
Prevent scripts from being injected on specific pages:
Exclude specific paths from injection:
/admin/* # Skip admin pages
/api/* # Skip API routes
/embed/* # Skip embed pages
/print/* # Skip print versions
Use wildcards or exact matches:
/checkout # Exact match
/checkout/* # Pattern match
*.pdf # File extension
NordicCDN provides pre-configured templates for common services:
Select a template and enter your ID/API key.
When multiple scripts are injected:
Ensure dependencies are ordered correctly (e.g., jQuery before plugins).
When scripts are modified:
Load scripts asynchronously to avoid blocking:
<script async src="..."></script>
<script defer src="..."></script>
Keep injected scripts small. For large scripts:
<script src="...">After adding scripts:
Exclude scripts from:
If scripts appear twice:
defer attribute