We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4e34bf3 commit 53cd69eCopy full SHA for 53cd69e
packages/experiment-tag/src/messenger.ts
@@ -49,6 +49,18 @@ export const asyncLoadScript = (url: string) => {
49
scriptElement.type = 'text/javascript';
50
scriptElement.async = true;
51
scriptElement.src = url;
52
+ // Set the script nonce if it exists
53
+ // This is useful for CSP (Content Security Policy) to allow the script to be loaded
54
+ const nonceElem = document.querySelector('[nonce]');
55
+ if (nonceElem) {
56
+ scriptElement.setAttribute(
57
+ 'nonce',
58
+ nonceElem['nonce'] ||
59
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
+ (nonceElem as any).nonce ||
61
+ nonceElem.getAttribute('nonce'),
62
+ );
63
+ }
64
scriptElement.addEventListener(
65
'load',
66
() => {
0 commit comments