如何加速jquery手机/ phonegap? [英] How to speedup jquery mobile / phonegap?

查看:130
本文介绍了如何加速jquery手机/ phonegap?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小的网络应用程序。共7页,总共3.6 KB index.html和855.5 KB。我唯一奇怪的是一个数据库(〜500kb)在Javascript中有很多行如:

  $。data(db, 'Aarstraße',['34236:1','34246:2','34270:4','34290:6',...] 



我在iPod / iPhone和Android(HTC Magic)上测试了它, p>

启动




  • iPhone:14秒

  • Android:21秒



简单页面转换(幻灯片)




  • iPhone:3-4秒

  • Android:4-6秒



<

我已经移除了框阴影



更新
$ b

我删除数据库,共有444.7KB的页面。现在它在Android上运行得更快。大约相同的一个iPhone。



http://stackoverflow.com/questions/9004308/jquery-mobile-transitions-judder-on-android/9004548\">这个问题,我切换到最新的jquery mobile build 。它将缓慢的Android设备的页面转换改进为每次转换大约2秒。版本1.1的发布将中/晚2月

解决方案

您可以执行以下操作:


  1. 获取deviceready更快

  2. 使用 YUI Compressor 最小化您的JS代码

  3. 将您的指令码标记移至body标记底部。

已经提到你已经把数据库移出了方程式,这可能需要大量的时间在启动。


I have a small web app. Seven pages, 3.6 KB index.html and 855.5 KB total. The only odd thing i have is a database (~500kb) in Javascript with many lines like:

$.data(db,'Aarstraße',['34236:1','34246:2','34270:4','34290:6',...]);

I tested it on iPod/iPhone and Android (HTC Magic) and it is very slow:

Startup

  • iPhone: 14 seconds
  • Android: 21 seconds

Simple page transition (slide)

  • iPhone: 3-4 seconds
  • Android: 4-6 seconds

How can I make this fast?

I already removed the box shadow.

Update

I remove the database leaving 444.7KB page total. Now it runs faster on Android. Around the same as one iPhone. It still feels very slow.

Update 2

After this question, I switched to the latest jquery mobile build. It improved the page transitions for slow Android devices to ~2 seconds per transition. Release of Version 1.1 will be mid/late February.

解决方案

There are a few things you can do:

  1. Get to deviceready faster.
  2. Minimize your JS code using YUI Compressor
  3. Move your script tags to the bottom of the body tag.

As you've already mentioned you've moved the database out of the equation which was probably taking a bulk of the time on startup.

这篇关于如何加速jquery手机/ phonegap?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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