I have (briefly) looked at Harmony loaders before but that is a spec for a 
future javascript language version.
I have found a module loader that I wish to use (require.js).

My point is that the current suggested module definition for cordova plugins 
INCLUDES a loader implementation.

I am suggesting that the loader implementation be removed from the plugin to a 
new method cordova.pluginLoader
This would make the plugins cleaner (as they would only describe their own 
behaviour) and it would also allow cordova or app developers to 
change/customize the loader implementation as needed.

My suggested approach would result in plugins that could be loaded in multiple 
different ways including (but not limited to); "classic" window.plugins, 
cordova.define and require.js


> From: [email protected]
> To: [email protected]
> Subject: RE: Suggestion - pluginLoader
> Date: Tue, 18 Jun 2013 15:08:27 +0000
> 
> Take a look at:
> http://wiki.ecmascript.org/doku.php?id=harmony:module_loaders
> https://gist.github.com/wycats/51c96e3adcdb3a68cbc3
> 
> That type of extensible loader could make sense in Cordova and seems like it 
> would meet all your requirements.
> 
> 
> -----Original Message-----
> From: J Prince [mailto:[email protected]] 
> Sent: Monday, June 17, 2013 7:27 AM
> To: [email protected]
> Subject: RE: Suggestion - pluginLoader
> 
> 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.
> 
>                                         
> 
                                          

Reply via email to