document.addEventListener('deviceready', this.onDeviceReady, false);
deviceready event is fired when Cordova APIs are loaded and ready to use.
deviceready
Using Cordova APIs without relying on this event could lead to unexpected results.