Skip to content

Commit

Permalink
LABjs.next: inlining same_domain() since only used once, and also s…
Browse files Browse the repository at this point in the history
…implifying the logic of it, since only used on already canonical URLs
  • Loading branch information
getify committed May 19, 2011
1 parent 689cc25 commit 36d9478
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions next/LAB.src.js
Expand Up @@ -53,9 +53,6 @@
// test for array
function is_array(arr) { return Object.prototype.toString.call(arr) == "[object Array]"; }

// test if script URL is on same domain as page or not
function same_domain(src) { return (canonical_uri(src,root_domain).indexOf(root_domain) == 0); }

// make script URL absolute/canonical
function canonical_uri(src,base_path) {
var protocol_relative_regex = /^\/\/[^\/]/, absolute_regex = /^\w+\:\/\//;
Expand Down Expand Up @@ -183,8 +180,8 @@
script.src = src;
append_to.insertBefore(script,append_to.firstChild);
}
// same-domain, so use XHR+script injection
else if (same_domain(src) && chain_opts[_UseLocalXHR]) {
// same-domain and XHR allowed, so use XHR+script injection
else if (src.indexOf(root_domain) == 0 && chain_opts[_UseLocalXHR]) {
var xhr = XMLHttpRequest ? new XMLHttpRequest() : (ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : null);
/*!START_DEBUG*/if (chain_opts[_Debug]) log_msg("start script preload (xhr): "+src);/*!END_DEBUG*/
xhr.onreadystatechange = function() {
Expand Down

0 comments on commit 36d9478

Please sign in to comment.