Skip to content

Instantly share code, notes, and snippets.

Last active October 9, 2015 07:11
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Load non-minified version of JS if debug=1 is present in
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 ("debug=1") > -1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment