You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Philipp Kursawe <ph...@gmail.com> on 2015/12/10 13:39:56 UTC

[DISCUSS] Loading plugins async or on demand

I am new to the list, and somewhat new to Cordova.

I wonder why all plugins are loaded before "deviceready" is emitted? I
understand for plugins that extend the hosts "navigator" object to mimic
webbrowser functionality like location or sensors you might want to have
them guaranteed to be accessible via global objects on "navigator" once the
app has been loaded.
Was there ever an async/on demand approach considered?
Like "cordova.getPlugin("plugin.google.maps").then(maps) {}"

I am asking because I would like to reduce the startup time. Loading the
webview already takes a lot of time. Loading all JS takes another fair
amount of time all the while cordova is busy loading all plugins. And I
don't need any of those plugins functionality right after startup.

Happy coding,
Phil

Re: [DISCUSS] Loading plugins async or on demand

Posted by Jesse <pu...@gmail.com>.
Thanks Philipp,

We have looked at this in the past. Attempts to 'fix' this will likely
fail, and take us in the wrong direction.
The goal is browserify as the mainstream way of packaging js, in which case
everything is in one file.
If you have scientific evidence of an issue, please post it, otherwise
let's continue on the path we're on.

Cheers,
  Jesse



@purplecabbage
risingj.com

On Fri, Dec 11, 2015 at 6:25 AM, Carlos Santana <cs...@gmail.com>
wrote:

> Can you open a JIRA and explain with more details what is taking most of
> the time when loading?
>
> Are the plugins taking time to load are core cordova plugins (i.e. camera,
> device, etc..)?
> We try to keep our scripts for clobbers/run/merge very light with no much
> work.
>
> You want to delay the injections and loading of the plugin js scripts?
>
> If you want to improve load time for your own plugin, maybe you are doing
> too much work in the scritps you specify in plugin.xml for merges and
> clobbers, run.
> What you can do is put the minimal amount of init and work in those
> scripts, and later when your plugin is used check if initialize and then do
> rest of the init there, including injecting scripts.
>
> We are planning to use browserfy to concat all the plugin js, and this
> should help at least with the loading of the script.
>
> Another point of is native code for the plugin, you can specify in your
> plugin to not load the native code on load of the webview, I believe the
> default is false, so it you have true for the custom plugins you are using
> maybe this is adding time to your load time
> <param name="onload" value="false" />
>
> example:
> <feature name="SuperPlugin">
>                 <param name="android-package" value="com.acme.superplugin"
> />
>                 <param name="onload" value="true" />
>   </feature>
>
>
>
>
> On Thu, Dec 10, 2015 at 9:13 AM Simon MacDonald <simon.macdonald@gmail.com
> >
> wrote:
>
> > When you say "fair amount of time" do you have any data on that? Before
> > spending time on a solution I'd want to make sure there is actually a
> > problem.
> >
> > What does the delay look like in Chrome/Safari web tools? I'd try running
> > an on various devices and seeing what the load times are for the JS on
> the
> > different platforms.
> >
> > Simon Mac Donald
> > http://hi.im/simonmacdonald
> >
> > On Thu, Dec 10, 2015 at 7:39 AM, Philipp Kursawe <phil.kursawe@gmail.com
> >
> > wrote:
> >
> > > I am new to the list, and somewhat new to Cordova.
> > >
> > > I wonder why all plugins are loaded before "deviceready" is emitted? I
> > > understand for plugins that extend the hosts "navigator" object to
> mimic
> > > webbrowser functionality like location or sensors you might want to
> have
> > > them guaranteed to be accessible via global objects on "navigator" once
> > the
> > > app has been loaded.
> > > Was there ever an async/on demand approach considered?
> > > Like "cordova.getPlugin("plugin.google.maps").then(maps) {}"
> > >
> > > I am asking because I would like to reduce the startup time. Loading
> the
> > > webview already takes a lot of time. Loading all JS takes another fair
> > > amount of time all the while cordova is busy loading all plugins. And I
> > > don't need any of those plugins functionality right after startup.
> > >
> > > Happy coding,
> > > Phil
> > >
> >
>

Re: [DISCUSS] Loading plugins async or on demand

Posted by Carlos Santana <cs...@gmail.com>.
Can you open a JIRA and explain with more details what is taking most of
the time when loading?

Are the plugins taking time to load are core cordova plugins (i.e. camera,
device, etc..)?
We try to keep our scripts for clobbers/run/merge very light with no much
work.

You want to delay the injections and loading of the plugin js scripts?

If you want to improve load time for your own plugin, maybe you are doing
too much work in the scritps you specify in plugin.xml for merges and
clobbers, run.
What you can do is put the minimal amount of init and work in those
scripts, and later when your plugin is used check if initialize and then do
rest of the init there, including injecting scripts.

We are planning to use browserfy to concat all the plugin js, and this
should help at least with the loading of the script.

Another point of is native code for the plugin, you can specify in your
plugin to not load the native code on load of the webview, I believe the
default is false, so it you have true for the custom plugins you are using
maybe this is adding time to your load time
<param name="onload" value="false" />

example:
<feature name="SuperPlugin">
                <param name="android-package" value="com.acme.superplugin"
/>
                <param name="onload" value="true" />
  </feature>




On Thu, Dec 10, 2015 at 9:13 AM Simon MacDonald <si...@gmail.com>
wrote:

> When you say "fair amount of time" do you have any data on that? Before
> spending time on a solution I'd want to make sure there is actually a
> problem.
>
> What does the delay look like in Chrome/Safari web tools? I'd try running
> an on various devices and seeing what the load times are for the JS on the
> different platforms.
>
> Simon Mac Donald
> http://hi.im/simonmacdonald
>
> On Thu, Dec 10, 2015 at 7:39 AM, Philipp Kursawe <ph...@gmail.com>
> wrote:
>
> > I am new to the list, and somewhat new to Cordova.
> >
> > I wonder why all plugins are loaded before "deviceready" is emitted? I
> > understand for plugins that extend the hosts "navigator" object to mimic
> > webbrowser functionality like location or sensors you might want to have
> > them guaranteed to be accessible via global objects on "navigator" once
> the
> > app has been loaded.
> > Was there ever an async/on demand approach considered?
> > Like "cordova.getPlugin("plugin.google.maps").then(maps) {}"
> >
> > I am asking because I would like to reduce the startup time. Loading the
> > webview already takes a lot of time. Loading all JS takes another fair
> > amount of time all the while cordova is busy loading all plugins. And I
> > don't need any of those plugins functionality right after startup.
> >
> > Happy coding,
> > Phil
> >
>

Re: [DISCUSS] Loading plugins async or on demand

Posted by Simon MacDonald <si...@gmail.com>.
When you say "fair amount of time" do you have any data on that? Before
spending time on a solution I'd want to make sure there is actually a
problem.

What does the delay look like in Chrome/Safari web tools? I'd try running
an on various devices and seeing what the load times are for the JS on the
different platforms.

Simon Mac Donald
http://hi.im/simonmacdonald

On Thu, Dec 10, 2015 at 7:39 AM, Philipp Kursawe <ph...@gmail.com>
wrote:

> I am new to the list, and somewhat new to Cordova.
>
> I wonder why all plugins are loaded before "deviceready" is emitted? I
> understand for plugins that extend the hosts "navigator" object to mimic
> webbrowser functionality like location or sensors you might want to have
> them guaranteed to be accessible via global objects on "navigator" once the
> app has been loaded.
> Was there ever an async/on demand approach considered?
> Like "cordova.getPlugin("plugin.google.maps").then(maps) {}"
>
> I am asking because I would like to reduce the startup time. Loading the
> webview already takes a lot of time. Loading all JS takes another fair
> amount of time all the while cordova is busy loading all plugins. And I
> don't need any of those plugins functionality right after startup.
>
> Happy coding,
> Phil
>