body script type text javascript var Loader loaded_scripts load functi

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<body>
<script type="text/javascript">
var Loader = {
loaded_scripts: [],
load: function (scripts, callback) {
var state = { n: scripts.length };
for (var i = 0; i < scripts.length; ++i) {
if (Loader.loaded_scripts[scripts[i]] !== undefined) {
--state.n;
continue;
}
state.src = scripts[i];
var s = document.createElement("script");
s.src = scripts[i];
s.type = "text/javascript";
s.async = "async";
s.onload = function () {
if (--state.n == 0) {
if (callback)
callback();
}
Loader.loaded_scripts[this.src] = 1;
};
document.body.insertBefore(s, document.body.firstChild);
}
}
};
Loader.load([
"http://spaces.ru/js/jquery.js?r=1911" + (new Date).getTime(),
"http://spaces.ru/js/cookie.min.js?r=1911" + (new Date).getTime(),
"http://spaces.ru/js/pushstream.js?r=1911" + (new Date).getTime(),
], function () {
console.log($('body'), new PushStream());
});
</script>
</body>