4

我使用包含几个 html 和 js 页面的 PhoneGap 和 JqueryMobile 框架构建了一个 android 应用程序。

第一次加载时间非常长(5-10 秒后与原生应用程序相比)并且页面导航太慢。

从一个屏幕导航到另一个屏幕需要花费大量时间。

是否有任何提示/操作方法/技巧来提高速度?对于经常使用的应用程序,它确实无法使用。

另一个问题是应用程序的内存使用量(一个简单的应用程序大约 50mb)

欢迎所有技巧和提示。

4

2 回答 2

7

A few optimization tips I have found to be helpful on slow devices:

  • Try changing the default page transition. Many Android devices do not support hardware accelerated features of the handset in the browser, which means that the CSS3 transitions that JQueryMobile tries to use by default are very slow. You can use:

    $.mobile.defaultPageTransition = 'none';
    

    to turn off all of the default transitions.

  • As far as script load time, there is not much you can do besides perhaps examining the individual load times for your dependencies and figuring out alternatives - but you can ensure that your app doesn't look wonky while it loads. Here's a quick hack I use:

    <style type="text/css">
      .doc {display: none;} /* don't show body by default */
    </style>
    
    <body id="main_body" class="doc"> 
    

    Once everything loads, I call

    $("#main_body").removeClass("doc");
    

    to show the application. I use a Javascript preloader (LABjs) in order to ensure all of my dependencies get loaded in order.

于 2012-12-08T19:43:19.670 回答
2

首先,不要使用像 jQuery 这样的重型框架,试试xuijs

于 2013-02-07T14:07:15.020 回答