This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Load non-minified version of JS if debug=1 is present in window.location.search. | |
This JS file can either be referenced in a master page with a <script> tag or via Custom Action. | |
Use of document.write ensures the script is inserted immediately below this one, synchronously. | |
For version string to successfully cache bust, the reference to this script also needs a query string that is updated each time this script is updated. | |
*/ | |
(function() { | |
var minUrl = "/script.min.js", | |
debugUrl = "/script.js", | |
versionString = "?v=123456"; // cache-busting query string - to be updated when the JS file changes | |
function addScriptTag(url) { | |
document.write("<script type='text/javascript' src='" + url + versionString + "'></script>"); | |
} | |
if (window.location.search.toLowerCase().indexOf("debug=1") > -1) | |
addScriptTag(debugUrl); | |
else | |
addScriptTag(minUrl); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment