JSFiddle - React, Tailwind, and code Playground
HTML
<html>
<head>
<script>
function getScript(url) {
let tag = document.createElement('script');
tag.src = url;
tag.onload = () => document.getElementById('console').innerHTML += url + " loaded<br>";
document.body.appendChild(tag);
}
function getFromCdnFirst() {
getScript('https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js');
}
function getFromCdnSecond() {
getScript('https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.slim.min.js');
}
function getIframeWithCSP() {
var doc = document.getElementById('iframe').contentWindow.document;
doc.open();
doc.write('<html><head><meta http-equiv="Content-Security-Policy" content="script-src https://cdn.ampproject.org/;object-src '+"'none';child-src blob:;frame-src 'none'" + '"></head><body>Test</body>');
doc.close();
}
</script>
</head>
<body>
<iframe id="iframe"></iframe><br>
<button onClick="getFromCdnFirst()">Get script</button><br>
<button onClick="getIframeWithCSP()">Get CSP</button><br>
<button onClick="getFromCdnSecond()">Get script</button><br>
<div id="console">
</div>
</body>
</html>