What is the difference between pure HTML5 app and native app?

Source: Internet
Author: User

What is the difference between pure HTML5 app and native app?

Wrote some pure H5 app, although the development is really very comfortable, but compared with the original pure H5app still have a lot of problems, mainly gathered in the following aspects:

1. Animation

There are many kinds of animations, such as the slide-out of the sidebar menu, the response animation of the elements, the transitions between page transitions, and so on, there is no way to achieve pure native performance in many implementations under H5. In general these words have several different options:

    • CSS3 Animation

    • JavaScript animations

    • Native animation

CSS3 animations are very performance-intensive, and if an element is used with CSS3 animations may not be visible, but large areas or scenes using CSS3 animation will make the app low-end phone experience very poor. The best option is to invoke the underlying animation through the framework, but regardless of how it is equivalent to wrapping a layer on the original code, performance is inevitably affected.

For example, in a new page loading, if you call the underlying animation to consider the problem has two, one is its own resource page rendering problem, the other is the acquisition of remote data. Even though these animations can respond quickly, a large number of CSS pages can cause the rendering to lag, and there may be white screen/machine lag when sliding. In order to solve these performance problems, it is necessary to use preloaded or simulated animations. Even so, sliding into the slide out of the animation on the low-end Android machine still have a lot of problems, if the way to get the server data processing is not appropriate, the phenomenon of white screen will be more serious. Look at the following data acquisition methods.

2. Get Server data

The first thing to accept is that the data obtained here is done asynchronously on the resource page, because this is the only way to make these resource pages pre-loaded or rendered. But the asynchronous get data in the page may involve Dom operation, it is known that the DOM operation is very expensive performance, if the page is good, the page slightly larger data is slightly more complex, frequent DOM operation will lead to significant flash white.

And the most important point is that if the page is loaded into the data update is too slow, it will make the page template to wait for a long time, the user experience is not friendly, always can not open every time like a browser to wait for the refresh is it.

If this problem is not solved, H5app is difficult to bear the large-scale data page, in which frequent switching is even more difficult, then certainly someone will think of the way of MVVM, actually I also wrote some h5app based on MVVM, Rather, they are more agile and scientific in the way they acquire data and update data, but they also pay attention to many of the H5 unique issues in the process of writing, which are described in the following page transitions.

3. Page switch

Above we see a few good implementations, such as preloaded and simulated animation, even batch pre-loading, batch simulation animation and so on, although it seems to be friendly to solve a lot of problems, but in fact, if enough pages will cause another problem-the life cycle of the page.

Imagine, if the boot page or the main page cache the resources of 5 sub-pages, when jumping to the child page of the response will cache the sub-pages of the child page resources, so repeatedly will occupy a lot of memory to make the experience of the app down. So how do you know which pages are needed, how many pages to cache, and when to end the life cycle of those pages? In many of the H5app frameworks I've used, there's no perfect answer to these questions, so in apps that have more content on the page, you might be able to reduce performance due to these resource allocation issues.

This is when we look back at the data loading problem with MVVM, and actually no matter which MVVM framework, the people who wrote it all know that the most important problem in managing this new type of front-end code is the memory problem, and you have to ensure that the code is written elegantly enough without any memory leaks. Also consider whether their controller/page resources are released at the end of the page life cycle, which has an impact on the global, and allocate resources reasonably in multiple requests, even the cache resources that are passed from those parent pages, and so on. Smaller apps may not have these problems, and if you want to use pure H5 to develop large apps, it's likely to waste a lot of your time-and the results won't make you happy.

4, the difference between Android/ios

A lot of people say that pure H5app can compile Android/ios two different apps in one write, which greatly reduces the cost. In fact, this view itself is questionable, if you write this kind of app can understand what I said, they are not easy, and there are many bugs, debugging is particularly cumbersome.

For a very simple example, there is a clear difference between how Android and iOS go back to the previous page, how the top bar of iOS is handled in full screen, how smart bar handles the layout of the page in the Android machine, how to distinguish different scenes when invoking the underlying hardware, etc. You need to write one-by-one model and system, and then debug on Android and iOS, and finally you find that it is not an egg, tired of dying but nothing learned, only a bunch of experience do not know when it will be outdated.

Now do H5 mixed app development of many people, but pure H5 is very young, many problems are not very good solution, these are I do these apps most of the issues to consider. Of course, we do not have to worry, with the implementation of ES6, hardware development more and more fast, pure h5app may not have no place. Finally said a few people notice the H5 advantage, we talk about H5app when the rapid development, low cost, multi-platform, and so on, but I think it and a lot of app development methods compared to a different-graphics and text mixed typesetting.

It is these complex and varied CSS styles that consume performance, but it brings a variety of typography, to be meticulous to each word wide line high and the style of pixel-level processing, is the H5 of excellence.

What is the difference between pure HTML5 app and native app?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.