From 11b4c9b4c454c98c88d418b101455bd5a72718c2 Mon Sep 17 00:00:00 2001 From: Carl Larson Date: Thu, 22 Feb 2018 12:32:01 +0000 Subject: [PATCH] check if document already interactive (DOMContentLoaded won't fire if already interactive) --- lib/contracts/code_templates/define-when-env-loaded.js.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/contracts/code_templates/define-when-env-loaded.js.ejs b/lib/contracts/code_templates/define-when-env-loaded.js.ejs index 186bd7e0..6b5a5784 100644 --- a/lib/contracts/code_templates/define-when-env-loaded.js.ejs +++ b/lib/contracts/code_templates/define-when-env-loaded.js.ejs @@ -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();