What are common sources of PhoneGap with jQuery Mobile performance issues?

前端 未结 8 1768
既然无缘
既然无缘 2021-01-30 18:14

I have an application written using PhoneGap 1.0 and jQuery Mobile 1.0b2 running on iPhone and iPad.

Ever since I started using the framework, I have been plagued by per

8条回答
  •  深忆病人
    2021-01-30 19:06

    One of the biggest differences between running your jQuery Mobile app in Safari and running it in UIWebView in native iOS is the lack of the Nitro engine. It was introduced in iOS 4.3. It made JavaScript processing about twice as fast in Safari but they failed to build it into native apps or fullscreen cached webapps. As of iOS 5, the Nitro engine was brought to the rest of the platform.
    http://arstechnica.com/apple/news/2011/06/ios-5-brings-nitro-speed-to-home-screen-web-apps.ars

    Beyond the Nitro engine, there are other possible performance issues surrounding jQuery Mobile and page transitions. The slower the platform, the more noticeable the flukes are. Sometimes it can manifest as a white flicker between page renderings. Other times, it can manifest as: transition to new screen - flash to previous screen - flash to new screen. These flukes are not consistent and can be hell to try to figure out exactly why it's happening. Newer and faster devices have less of a problem with this so the good news is, over time, this problem will disappear. Build for the future, devices will soon catch up.

    That being said, let's also consider performance in terms of how fast users are able to click what they want. Transition quirks are minimized by disabling page transitions. This gives the added benefit of increasing your effective page performance by 500 milliseconds. Page transitions are pretty, but the fact is, they're slow. Performance is a feature. Just turn off the transitions by including this in your custom scripts.

    $(document).bind("mobileinit", function(){
      $.mobile.defaultPageTransition="none";
    });
    

    Also, (and this goes out to the community at large that might read this)... seriously consider if you need to actually have a native app. Unless you need PhoneGap to access the camera, gyroscopes, or some other piece of hardware support that Safari can't offer, you'll always get better performance by just using the web. I understand the desire to have a presence to have an an "app store" but only 1% of apps are ever discovered and their half life is only a few weeks. Then you have the maintenance nightmare of releasing updates whenever there's an update to the OS. There are a lot of advantages to just releasing only over the web. With a single update, you can have everyone on every platform updated. So, consider the performance of the platform, but also consider the performance of your releases.

提交回复
热议问题