Skip to content

Instantly share code, notes, and snippets.

@DimitarChristoff
Created July 4, 2011 15:18
Show Gist options
  • Save DimitarChristoff/1063474 to your computer and use it in GitHub Desktop.
Save DimitarChristoff/1063474 to your computer and use it in GitHub Desktop.
xpath experiment
this.replaceURL = function(old, newurl) {
var x = document.evaluate('//script[@type="text/javascript" and @src="'+old+'"]', document, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
var oldScript = x.iterateNext();
if (!oldScript)
return;
oldScript.src = newurl;
console.log(oldScript);
};
replaceURL("http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js", "http://ajax.googleapis.com/ajax/libs/mootools/1.3.2/mootools-yui-compressed.js");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment