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();