I know that an app developed with PhoneGap is slower than a native one because at PhoneGap the whole code must be interpreted at runtime into a native one.
But could someone explain or has a good in-depth website which explains why a native app retrieves data (a picture or text) from a web ressource faster than an app with PhoneGap? Do both apps handle internet connections in another way, or is there more data retrieved by an PhoneGap app?
3
It’s a totally different application event process.
PhoneGap uses JavaScript event callbacks that are designed to be generic across multiple devices, whereas Android is activity based which is native to the OS. iOS has something simular but I can’t comment on that.
Android knows which activity to start when the application is loaded, and execution of that activity happens relatively quickly even for large applications. Whereas, PhoneGap requires a HTML5 browser to finish loading, then all the HTML5 JavaScript files have to load from the device and the JavaScript has to be executed at least once to initialize all the code. As a result there is a visible delay in starting PhoneGap applications. That’s why PhoneGap includes a splash screen feature while the app loads.
After a PhoneGap application has started the entire user interface is a rendered HTML page, which is subject to performance issues relative to the device it’s on. Whereas, native Android applications often use the OS to render their activity view. So improvements in the speed of the OS translate to faster apps. HTML rendered by a browser is limited to the speed of the processor and GPU.
Performance Should Be The Same When
- Applications can take advantage of local storage, caching and SQL.
- Communication with the web server is done via AJAX (JSON, XML or HTML).
Performance Should Be Different
- Javascript is used to perform large calculations.
- The user interface displays data from a large data source.
- Read/Write operations to local storage are in large amounts (i.e. camera images)
- All visual elements that involve animation or large graphics would be faster done natively.
Hybrid PhoneGab
There is no good reason for a PhoneGap developer to complain about performance. PhoneGap allows you to develop code for each device that runs natively, and can be executed via a plugin to PhoneGap. The native plugin is exposed to the PhoneGap app as a Javascript extension. Any time performance is an issue the developer has the option to move that code to a native plugin.
While JavaScript is slower than native code. What is it the code is doing that makes it so slow? Most likely it’s bad Javascript then a fault in the design of PhoneGap.
Why PhoneGab?
PhoneGab is not Android development. It’s HTML5 and personally the Android SDK can allow you to achieve results often faster than implementing the same thing in HTML. I think people who have strong skills in HTML/Javascript have very specific user interface expectations, and recoil at the idea of the OS imposing standards.
0