Skip to content

Commit

Permalink
avoid using Object.keys (ES5) by changing dependencies map to array w…
Browse files Browse the repository at this point in the history
…ith object elements
  • Loading branch information
ericz committed Jun 2, 2011
1 parent 93d7d3f commit eefd410
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/now.js
Expand Up @@ -385,14 +385,14 @@ var now = {
};

(function(){
var dependencies = {
'io': '/socket.io/socket.io.js'
};
var dependencies = [
{ key: 'io', path: '/socket.io/socket.io.js'}
];
var dependenciesLoaded = 0;

var nowJSScriptLoaded = function(){
dependenciesLoaded++;
if(dependenciesLoaded !== Object.keys(dependencies).length) {
if(dependenciesLoaded !== dependencies.length) {
return;
}

Expand All @@ -410,17 +410,14 @@ var now = {
});
};

for(var ns in dependencies){
if (!dependencies.hasOwnProperty(ns)) {
continue;
}
if (window[ns]) {
for(var i=0, ii=dependencies.length; i < ii; i++){
if (window[dependencies[i]['key']]) {
nowJSScriptLoaded();
return;
}
var fileref=document.createElement('script');
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", "http://**SERVER**:**PORT**"+dependencies[ns]);
fileref.setAttribute("src", "http://**SERVER**:**PORT**"+dependencies[i]['path']);
fileref.onload = nowJSScriptLoaded;
if(isIE) {
fileref.onreadystatechange = function () {
Expand Down

0 comments on commit eefd410

Please sign in to comment.