Why is PhoneGap slower than Browser?

Matt Zukowski picture Matt Zukowski · Aug 28, 2012 · Viewed 9.5k times · Source

I'm running the same exact web app on Android under PhoneGap and under the built in Browser. The app runs fine on the built-in browser but is unbelievably slow under PhoneGap. Even basic scrolling on the page stutters under PhoneGap.

Is there anything, in general, that I might be doing wrong? I was under the impression that PhoneGap just uses the same WebKit renderer as the normal Browser app, so why would the same HTML and JavaScript run much slower inside PhoneGap?

P.S. This has been asked before, but due to wording I think the original question was misunderstood.

Answer

Matt Zukowski picture Matt Zukowski · Sep 13, 2012

I may have inadvertently stumbled on an answer to this. Turns out that the apps I was working on had android:targetSdkVersion in AndroidManifest.xml set to a really low value (i.e. my target Android version was something like 2.2). Increasing this to 14 (Android 4.0) appears to have hugely improved PhoneGap performance, at least on newer Android devices running ICS or Jelly Bean.

Setting a low targetSdkVersion seems to disable at least some of the performance improvements introduced in newer versions of Android.

So, if you want to see a big performance boost in PhoneGap, make sure your targetSdkVersion matches the max SDK version supported by the phone you're testing on.