Optimizing cordova plugins loading

Viewed 89

I'm building a cordova app and I have a problem with plugins slowing down my app's initialization.

enter image description here

The screenshot above shows the plugins taking up 4s from when they're injected to when they finish loading. This doesn't include the other scripts and assets that my app uses, so this is really expensive. Has anyone come up with a way to optimize the plugins loading? There's this thread from some years ago but it doesn't contain a lot of actionable info. My case looks like death by a thousand cuts because I use a number of plugins and in total they inject more than 130 scripts into the <head> tag during app init. It seems as though each script does just a little bit of work, but together they take up a large chunk of time. Any ideas/suggestions apart from just using fewer plugins? I'm considering forking the plugins and modifying them to load each function using dynamic import() when I actually invoke the function. Does anyone know or sense any shortcomings/concerns with such a strategy? I've also noticed that the initial load event after parsing the cordova.js file doesn't fire until around 3s into app init, so this 4s chunk of time only begins 3s into app init, giving me at least 7s of delay before deviceready fires, so most of my app's main logic can't run during this period. Really quite expensive. Open to any ideas, thanks in advance. These are the plugins I use:

pushy-cordova
branch-cordova-sdk
com.googlemaps.ios
cordova-background-geolocation
cordova-plugin-background-fetch
cordova-plugin-actionsheet
cordova-plugin-android-notch
cordova-plugin-android-permissions
cordova-plugin-camera
cordova-plugin-contacts
cordova-plugin-datepicker
cordova-plugin-dialogs
cordova-plugin-enable-multidex
cordova-plugin-file-transfer
cordova-plugin-googlemaps
cordova-plugin-googleplus
cordova-plugin-inappbrowser
cordova-plugin-ionic-keyboard
cordova-plugin-ionic-webview
cordova-plugin-ios-camera-permissions
cordova-plugin-local-notification
cordova-plugin-device
cordova-plugin-badge
cordova-plugin-media-capture
cordova-plugin-file
cordova-plugin-native-logs
cordova-plugin-network-information
cordova-plugin-purchase
cordova-plugin-splashscreen
cordova-plugin-statusbar
cordova-plugin-video-editor
cordova-plugin-whitelist
cordova-plugin-x-socialsharing
cordova-sqlite-storage
cordova.plugins.diagnostic
es6-promise-plugin
pushy-cordova-receiver
rollbar-cordova
cordova-android-support-gradle-release
cordova-plugin-androidx-adapter
0 Answers
Related