What is the best approach to run (or bootstrapping) an angular-cli based app on Cordova?
Note: This is for an Angular 4.x app for which multiple Cordova plugins are being used.
Option A: Post ng build, in your www/index.html (www is Cordova folder) should you do something like:
<script src="cordova.js"></script>
<script>
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
console.log('onDeviceReady has been called. Lets start loading JS files.');
var url = ['inline.bundle.js', 'polyfills.bundle.js', 'styles.bundle.js', 'vendor.bundle.js', 'main.bundle.js'];
for(var i = 0; i < url.length; i++){
loadJSFile(url[i]);
}
}
function loadJSFile(url) {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
head.appendChild(script);
}
</script>
OR,
Option B: The onDeviceReady() can go somewhere inside main.ts (before bootstrapping AppModule), or app.component.ts.
I have tried Option A, but my app is taking too long to load on iPad. So I wanted to know if I am following a good approach or not. Thanks in advance for your suggestions.