commento.js: attempt load on readystatechange
This commit is contained in:
parent
590e878679
commit
f1625b4274
@ -54,6 +54,7 @@
|
|||||||
var cdn = global.commentoCdn;
|
var cdn = global.commentoCdn;
|
||||||
var root = null;
|
var root = null;
|
||||||
var cssOverride = undefined;
|
var cssOverride = undefined;
|
||||||
|
var autoInit = undefined;
|
||||||
var isAuthenticated = false;
|
var isAuthenticated = false;
|
||||||
var comments = [];
|
var comments = [];
|
||||||
var commenters = [];
|
var commenters = [];
|
||||||
@ -1366,11 +1367,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var autoInitted = false;
|
var initted = false;
|
||||||
function autoInit() {
|
function init() {
|
||||||
if (autoInitted)
|
if (initted)
|
||||||
return;
|
return;
|
||||||
autoInitted = true;
|
initted = true;
|
||||||
|
|
||||||
dataTagsLoad();
|
dataTagsLoad();
|
||||||
|
|
||||||
@ -1381,9 +1382,28 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (document.readyState != "complete" && document.readyState != "interactive")
|
var readyLoad = function() {
|
||||||
document.addEventListener("load", autoInit);
|
var readyState = document.readyState;
|
||||||
else
|
|
||||||
autoInit();
|
if (readyState == "loading") {
|
||||||
|
// The document is still loading. The div we need to fill might not have
|
||||||
|
// been parsed yet, so let's wait and retry when the readyState changes.
|
||||||
|
// If there is more than one state change, we aren't affected because we
|
||||||
|
// have a double-call protection in init().
|
||||||
|
document.addEventListener("readystatechange", readyLoad);
|
||||||
|
}
|
||||||
|
else if (readyState == "interactive") {
|
||||||
|
// The document has been parsed and DOM objects are now accessible. While
|
||||||
|
// JS, CSS, and images are still loading, we don't need to wait.
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
else if (readyState == "complete") {
|
||||||
|
// The page has fully loaded (including JS, CSS, and images). From our
|
||||||
|
// point of view, this is practically no different from interactive.
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
readyLoad();
|
||||||
|
|
||||||
}(window, document));
|
}(window, document));
|
||||||
|
Loading…
Reference in New Issue
Block a user