More reliable document ready detection.
This commit is contained in:
@@ -134,7 +134,7 @@ var Cosmopolite = function(
|
|||||||
if (document.readyState == 'complete') {
|
if (document.readyState == 'complete') {
|
||||||
this.init_();
|
this.init_();
|
||||||
} else {
|
} else {
|
||||||
document.addEventListener('DOMContentLoaded', this.init_.bind(this));
|
document.addEventListener('readystatechange', this.init_.bind(this));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -508,6 +508,10 @@ Cosmopolite.prototype.trackEvent = function(var_args) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
Cosmopolite.prototype.init_ = function() {
|
Cosmopolite.prototype.init_ = function() {
|
||||||
|
if (document.readyState != 'complete') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Promise}
|
* @type {Promise}
|
||||||
* @private
|
* @private
|
||||||
|
|||||||
Reference in New Issue
Block a user