[iOS] Optimizations for App Mix (Hybrid) development, including H5, Weex, etc. (this blog is primarily for iOS apps, but the idea applies to Android too)

Source: Internet
Author: User

We know that hybrid development can save a lot of cost (time cost, economic cost, etc.), so a lot of companies prefer this form of development, and today the optimization is what I used in our company's application, and I wrote this optimization of the SDK has been open source to GitHub, Interested students can download to see, there is insufficient place to welcome correct. Here is the link: https://.

Reprint Please specify source: http://www.cnblogs.com/shisishao/p/6830736.html

-First of all, let's introduce what is hybrid development:

We usually divide mobile development into web, native and hybrid, but in fact hybrid can be subdivided. The simplest is to put a webview in the native, and then load a compatible phone site, in fact, the equivalent of a user's mobile phone to establish a shortcut, but also occupy the user's desktop emergency usage bar. Use this method to pay attention to check whether the network is normal, abnormal to give hints, otherwise Apple will not pass. The second is to put the web-related files on the local, database-like with SQLite to do local storage, users even if the network can work, or to native-based, in some specific modules will be used WebView.

In fact, I have to say that only the second kind of real hybrid. It is important that native and the web have no interaction, no, you directly in the WebView loading an HTML page, this is what kind of hybrid development, this is not what technical content, there is nothing good to say. This development is difficult to simulate native experience, the user at a glance that this is the Web page, I said the hybrid development is the kind of most users do not travel, this blog is also for the second type of optimization.

Second, according to the strategy, to achieve the optimization of different scenarios: (Here we take the Web build JS file As an example, of course Weex is the same truth)

1, if your application in the JS file is deployed to the remote server, that is, every access to a WEB interface, is based on the URL to download the page JS file and then loaded out, this time in fact there is a disadvantage, that is, every time I enter the same interface, to download the interface of the JS file. There is no way, let me only need to download once, the next time to enter will not have to download, but the direct loading has been downloaded well? The answer is yes. Next, we will focus on how to achieve this approach: that is, when the application starts, we first download all of the JS compressed file package--and then unzip--------and then load, the implementation:

(1) Each time the application starts, we first request a background interface, used to tell us: there is no new JS package to download and, if there is to download, this time there is a problem, if my JS package has not been downloaded to finish I will point into a Web interface how to do, this time not show it? Don't worry, we are not also the server on the cable, so, every visit to a WEB interface, we first want to determine the local (in the sandbox or called hard disk) there is no corresponding JS file (can be judged according to the URL link), if there is a local JS file, if not go to remote download. This time does not solve the JS package did not download the completion of the problem of the interface, haha perfect, so, since we are talking about optimization, it is impossible to affect the normal use, but on the basis of normal use to enhance the user experience, or how can be called optimization it.

(2) Update JS package: Each time you update the server's JS file on the line, this time the application to download the JS package also to update, that is, to maintain two documents unified.

2, if your application in the JS file is integrated in the project, that is, in your. IPA package. This time will also have some drawbacks, for example, my own native code is not updated, but my JS file updated, this time need to AppStore upload a new version, and then wait for Apple long audit. Is there any way that I can update the old JS package without submitting the new application? Of course there is a way to do it, and the next is the time to witness miracles:

(1) This scenario is the same as the first update, that is, in each visit to a WEB interface, we have to determine the local (in the sandbox or called hard disk) there is no corresponding JS file (can be judged according to the URL link), if there is a local JS file access, if not to access the project integrated JS file.

Iii. Summary

The optimization is mainly to improve the user experience, not to let users open your application will give people a very low feeling. Various WEB interfaces are loaded for half a day, and there may be situations where loading fails. If a classmate wants to optimize this piece of things can refer to my above said I wrote the SDK, the scene of the test is still relatively full, because it is our own application in use, what questions welcome message discussion.

 

[iOS] Optimizations for App Mix (Hybrid) development, including H5, Weex, etc. (this blog is primarily for iOS apps, but the idea applies to Android too)

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.