There are a few main reasons. 1. The app I am working on is an Enterprise app. We are designing the app as a Cordova shell that re-directs to all the html content. This means that we have to dynamically load a different cordova.js (depending on platform) following the redirect. So we are actually unable to do anything other than dynamically load plugins once the platform specific cordova.js is loaded
2. Some of the plugins will be used incredibly rarely. It doesn't seem necessary to always load plugins until they are needed. 3. We are building with a single page architecture so don't want to end up with lots of script includes in the index.html page. The define/require pattern feels much cleaner and better compartmentalized. Our main page currently has 2 script includes: require.js and jqmobi. I am already doing something similar to what I proposed in my project. As this is actually a small change and results in a plugin definition that is compatible with the current cordova.define approach, the old window.plugins, and my own use case I thought it would be worth suggesting it to you. I wasn't sure how this might affect any planned changes to plugins so didn't feel it was worth diving in with a pull request. This is a new feature and would not break any existing plugins. It would also allows developers (or the cordova team in future) to customize/change how they wish plugins to be loaded. > Date: Mon, 17 Jun 2013 04:05:52 -0700 > Subject: Re: Suggestion - pluginLoader > From: [email protected] > To: [email protected] > > Hey Jonathan, looks super interesting. I'd like to better understand > the motivations / use case. So, can you describe more about why you > want to dynamically load modules for a plugin? > >
