Skip to content

Instantly share code, notes, and snippets.

@Ghepes
Last active June 12, 2024 20:17
Show Gist options
  • Save Ghepes/464dc57e06890198e450a8da773206d2 to your computer and use it in GitHub Desktop.
Save Ghepes/464dc57e06890198e450a8da773206d2 to your computer and use it in GitHub Desktop.
nonce
<!-- EXEMPLE css nonce CSP -->
<link rel="stylesheet" media="all" href="https://domain.a.com/a/file/style.css" nonce="">
<!-- EXEMPLE js nonce CSP -->
<script nonce="">
// Codul scriptului
</script>
<!-- EXEMPLE js nonce CSP -->
<script src="index-file.js" nonce=""></script>
<!-- EXEMPLE nonce -->
function createStyleSheet(media, nonce) {
// Create the <style> tag
var style = document.createElement("style"); // style.setAttribute("type", "text/css");
// Add a media (and/or media query) here if you'd like!
// style.setAttribute("media", "screen")
// style.setAttribute("media", "only screen and (max-width : 1024px)")
if (media) {
style.setAttribute("media", media);
} // Add nonce attribute for Content Security Policy
if (nonce) {
style.setAttribute("nonce", nonce);
} // WebKit hack :(
// style.appendChild(document.createTextNode(""));
// Add the <style> element to the page
<!-- EXEMPLE nonce -->
var tns = function (options) {
options = extend({
nonce: false
}, options || {});
var doc = document,
},
sheet = createStyleSheet(null, getOption('nonce')),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment