PhoneGap应用程序可以启动多快?提示加快? [英] How fast typical PhoneGap app can be started? Tips to speed up?

查看:143
本文介绍了PhoneGap应用程序可以启动多快?提示加快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道你可以做多快,你可以使简单的PhoneGap应用程序加载。
我的简单的应用程序需要6-8秒在Galaxy S3(所有资源都存储在本地驱动器)。不确定PhoneGap是否正常。

I wonder how fast you could make simple PhoneGap app loaded. My simple app takes 6-8 seconds on Galaxy S3 (all resources are stored in local drive). Not sure whether it is normal for PhoneGap.

任何人都可以超过2-3秒加载时间?有什么提示可以加快加载速度吗?

Any one can beat 2-3 seconds loading time? Any tips to make it load faster?

推荐答案

传闻数据:

我的phonegap应用程序可以加载在2秒钟(从点击图标)在iPad 3.即使如此,建议您使用启动屏幕插件来保持飞溅,直到应用程序的UI加载,以防止任何闪烁等

My phonegap apps can load in 2 seconds (from tapping the icon) on an iPad 3. Even so, you are advised to use the splash screen plugin to maintain the splash until your app's UI has loaded so as to prevent any flickering, etc.

您可以做的事情:

1)不要等待您的数据开始显示您的用户接口。

1) Don't wait on your data to start displaying your user interface.

在我的一个应用程序中,文件系统提供后台数据。虽然文件系统很快,但没有理由在等待用户界面时阻止其初始显示。虽然会有一个初始的空白接口一会儿,这是可以的 - 事实上,苹果的初始屏幕的准则是显示用户界面,如果它是未填充。 (不是大多数人同意或遵循建议)。

In one of my apps, the file system provides the backing data. Although the file system is fast, there's no reason to block the initial display of the user interface while waiting for it. Although there will be an initial blank interface for a moment, this is OK -- in fact, Apple's guidelines for splash screens are to show the user interface as if it were unpopulated. (Not that most people agree or follow the advice).

这同样适用于您加载任何网络数据 - 尽快显示UI一个缓慢加载应用程序的感觉。然后,如果你的数据加载缓慢,放一个微调。

The same holds true if you are loading any network data -- show the UI as soon as you can to eliminate the feeling of a slow-loading app. Then if your data is going to be slow to load, put up a spinner. The user will see that your app has loaded quickly and that the network is now the bottleneck.

2)减少起始资产的大小/数量

2) Reduce the size/number of starting assets

启动时加载的脚本,样式表等越少越好。大多数Web视图都尽可能地管理这些视图,但是从根本上来说,Web视图需要加载的数据越多,只是为了显示您的UI,您的应用的加载时间会越慢。 (这就是为什么苹果的建议,启动屏幕有意义:几乎立即显示一个unpopulated UI应该帮助用户觉得应用程序已经快速加载,即使没有,我不完全相信这个参数。 。)

The fewer scripts, stylesheets, etc., that you can load at startup, the better. Most web views are reasonably good at pipelining these as much as possible, but fundamentally the more data the web view needs to load just to show your UI, the slower the load time of your app will be. (This is why Apple's advice for the splash screens make sense: showing an unpopulated UI nearly immediately is supposed to help users feel that the app has loaded quickly, even when it hasn't. I'm not entirely convinced by that argument...!)

实质上,您应该尝试加载生成未填充UI所需的最少数量的资产,然后在显示后加载剩余资产。如果这将需要时间,抛出一个微调。

Essentially, you should try to load the bare minimum number of assets required to generate an unpopulated UI, and then load the rest in after it is displayed. If this is going to take time, throw up a spinner.

3)将插件数量减少到应用程序功能所需的裸露数量

3) Reduce the number of plugins to the bare number required for your app's functionality

插件需要时间初始化,并且它们在调用 deviceready 之前这样做。你有越多的插件,必然,你的应用程序需要更长的时间。如果你可以在 deviceready 之前抛出一个未填充的UI,但是这只有在你不完全依赖于一个或多个插件加载。 )

Plugins take time to initialize, and they do so prior to deviceready being called. The more plugins you have, necessarily, the longer your app takes to get going. You can mitigate this to some degree if you can throw up an unpopulated UI prior to deviceready, but this only works if you aren't completely dependent on one or more plugins being loaded. Again, this is why the splash screen plugin is useful.)

4)在启动时避免任何复杂的计算,直到UI显示之后

4) Avoid any complex computation at startup until after the UI is presented

如果可能的话,当然。即使您的应用程序需要推送数据(例如在首次启动时创建数据库),先抛出UI,然后在处理数据时使用微调器。如果你的应用需要计算复杂的东西,先抛出UI,然后敲碎你的数字。

If possible, of course. Even if your app needs to push data around (say to create a database upon first launch), throw the UI up first, and then a spinner while the data is handled. If your app needs to calculate something complex, throw up the UI first, and then crunch your numbers.

5)了解一些加载时间不受您的控制

5) Understand that some of the load time is out of your control

本地封装程序必须加载,然后必须初始化一个Web视图(这需要时间),然后必须加载cordova.js(为了在本地和Web端之间的接口)。这是你真的不能避免的东西(虽然你可以避免cordova.js如果你没有使用任何Cordova的功能,但然后为什么不只是构建一个更简单的shell在这种情况下 - 不需要使用Cordova。 )

The native wrapper has to be loaded, which then has to initialize a web view (which takes time), which then has to load cordova.js (in order to interface between the native and web sides). This is stuff you really can't avoid (although you could avoid cordova.js if you weren't using any of Cordova's functionality. But then why not just build a simpler shell in that case -- no need to use Cordova at all.)

6)设备差别很大

当然,一个设备上的加载时间没有轴承, - 在另一个设备上。这在任何平台上都是如此,虽然我怀疑它在Android上更明显,因为设备的成本范围很大。一个缓慢的Android设备显然需要花费更长的时间来加载您的应用程序,而不是一个顶级的Android模型。对于较新的设备也是如此。例如,如果我的应用程序可以在一个全新的iPad上加载2s,机会是好的,将需要稍长的老硬件。 (对我来说,我想如果我可以在iPad 3 - 这不是最新的 - 它应该加载更快的新的硬件上2-3秒加载应用程序)。

Of course, a load time on one device has no bearing, what-so-ever on another device. This is true on any platform, though I suspect it's more visible on Android due to the wide cost range of devices. A slow android device is obviously going to take far longer to load your app than a top-of-the-line android model. The same generally holds true for newer devices as well. For example, if my app can load in 2s on a brand new iPad, chances are good it will take slightly longer on older hardware. (For me, I figure that if I can load the app in 2-3 seconds on an iPad 3 -- which isn't the newest -- it should load even faster on newer hardware).

最后:

我不确定你会得到低于1-2秒的负载时间这里。我还可以说,2-3秒的加载时间通常不难实现 - 我没有把任何特殊的努力,我的大多数应用程序,他们加载快速,有效率。 (事实上​​,我的一个原生应用程序加载比我的phonegap应用程序慢 - 4秒对比2-3。)

I'm not sure you're going to get much below 1-2 second load times here. I can also state that 2-3 second load times is usually not hard to achieve -- I haven't put any special effort into most of my apps, and they load quickly and efficiently. (In fact, my one native app loads more slowly than my phonegap apps -- 4 seconds vs 2-3.)

这篇关于PhoneGap应用程序可以启动多快?提示加快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆