code: function canonical_uri(src,base_path) {
  		var absolute_regex = /^\w+\:\/\//;
  
  		// is `src` is protocol-relative (begins with // or ///), prepend protocol
  		if (/^\/\/\/?/.test(src)) {
  			src = location.protocol + src;
  		}
  		// is `src` page-relative? (not an absolute URL, and not a domain-relative path, beginning with /)
  		else if (!absolute_regex.test(src) && src.charAt(0) != "/") {
  			// prepend `base_path`, if any
  			src = (base_path || "") + src;
  		}
  		// make sure to return `src` as absolute
  		return absolute_regex.test(src) ? src : ((src.charAt(0) == "/" ? root_domain : root_page) + src);
  	}
docs: make script URL absolute/canonical