commento.js: use a separate function to autoload
This commit is contained in:
parent
877a9bf09f
commit
93b842c5d4
@ -1294,13 +1294,18 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// There's no danger of both main()s being called because if the first one is
|
var autoInitted = false;
|
||||||
// called later, the second `main()` wouldn't have executed because readyState
|
function autoInit() {
|
||||||
// woldn't have been "interactive" or "complete" at registration. If the
|
if (autoInitted)
|
||||||
// second main() executes, the first would never execute because
|
return;
|
||||||
// DOMContentLoaded wouldn't be fired in the future.
|
autoInitted = true;
|
||||||
document.addEventListener("DOMContentLoaded", main);
|
|
||||||
if (document.readyState == "interactive" || document.readyState == "complete")
|
|
||||||
main();
|
main();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.readyState != "complete" && document.readyState != "interactive")
|
||||||
|
document.addEventListener("load", autoInit);
|
||||||
|
else
|
||||||
|
autoInit();
|
||||||
|
|
||||||
}(window, document));
|
}(window, document));
|
||||||
|
Loading…
Reference in New Issue
Block a user