var whenEnvIsLoaded = function(cb) { if (typeof document !== 'undefined' && document !== null) { document.addEventListener('DOMContentLoaded', cb); } else { cb(); } }