check if document already interactive (DOMContentLoaded won't fire if already interactive)

This commit is contained in:
Carl Larson 2018-02-22 12:32:01 +00:00
parent 6e51b45c7f
commit 11b4c9b4c4
1 changed files with 1 additions and 1 deletions

View File

@ -1,5 +1,5 @@
var whenEnvIsLoaded = function(cb) {
if (typeof document !== 'undefined' && document !== null) {
if (typeof document !== 'undefined' && document !== null && !/comp|inter|loaded/.test(document.readyState)) {
document.addEventListener('DOMContentLoaded', cb);
} else {
cb();