Improve HTML5 performance Experience series of five WebView start speed optimization and event sequence resolution]

Source: Internet
Author: User

WebView loaded with 3 events. The triggering sequence is loading, titleupdate, loaded.
WebView triggers loading when the page starts loading
If the title has been parsed and given a new value during onboarding, the titleupdate is triggered,
Load complete trigger loaded.

If the page is loaded fast enough, then titleupdate and loaded are triggered almost simultaneously.
If the page loads too slowly, the loaded is triggered when all loading is complete.

Loaded is often used to determine whether the page is loaded, and the new page is displayed when loading is complete.
However, sometimes the page content is very long, all loading is slow, resulting in a slow display of the new form. In order for the new form to open quickly, we can display the new form when titleupdate.
Because the Web page itself has the mechanism of step rendering, so as long as the first screen page rendering finished will not let the user see white screen.

Someone asked the plus ready and domcontentloaded, onload, and the order of the above 3 events.
Plus the ready and HTML original events are asynchronous parallel, not necessarily who is fast.
But there are some basic rules.
First of all, the new WebView loading is at the beginning of the trigger.
And then the titleupdate of the new WebView,
Then there's the HTML domcontentloaded in the new WebView,
In general, new WebView plus ready takes place after domcontentloaded,
Then there is the loaded event of the new WebView.
Finally there is an onload event in the body of the new page.

Also provides a way to judge WebView loading time.
General WebView How long it takes to load, developers can use their own timer to calculate the time difference from the start load to the loaded.
But the loading speed of the home page developers can not be programmed to obtain, 5+runtime provides the first page of the WebView loading time, plus.runtime.launchLoadedTime.
The biggest use of time is to judge the performance of the phone.
Home Normal is a local page, the same home on different phones loadedtime value is different, according to this value, you know how fast this mobile phone loading page.
This speed is related to native IO performance and also to rendering capability.
Based on this value, we can do a lot of optimizations.
For example, on some high-performance mobile phones, loading a new form quickly, resulting in a snowflake flash and immediately disappear, there is no need to make snowflakes appear, directly cut the screen is good. Low-performance phones, which are loadedtime low, turn to snowflakes honestly.

Improve HTML5 performance Experience series of five WebView start speed optimization and event sequence resolution]

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.