So I understand that when script tags are executed it's in the global scope, I was wondering if there was any way to make them execute in a local scope. For example:
function scoped() {
const scopedVariable = '10';
const scr = document.createElement('script');
scr.src = '//cdn.blabla.com' //third party script
document.body.appendChild(scr);
}
What I want is for the code that's executed in the script to have access to the scopedVariable. Meaning, I want the script to be executed within the scoped() execution context.