I just don’t love writing this on January 9, huh

Yeah, but I still scraped a hot spot once, so my body’s honest.

As we all know, on January 9, wechat released a small program, and there was a lot of crying in various groups I was in. A group of frustrated Android engineers said that the App was going to die and they would lose their jobs. I especially do not like to follow the flow of the people, and disdain to “ha ha” under. Of course, the target of the ridicule is not the small program, but the Android engineers.

Many of them love to follow the big man to talk about the trend, the development of the industry, the general direction, financial freedom, and to find that there is not a few cents in the wallet, to understand that this is not in line with the “class attribute” of a topic. It’s not that it’s wrong to talk about it, it’s wrong to live through it.

Ask yourself, how much are you substitutable after all? Would the company be in trouble without you? Are you a popular programmer with employers? If you answered no to all three, it’s time to rethink your ability to learn. After all these years of college and all these years of work, you’re still way behind everyone else on this one, and it’s only getting worse because of it.

Digression, the purpose of this article is to pull out the Android programmers and criticize them, and then look at the applets.

Constitute a

The SDK for applets was released a long time ago, which reminded me of React. Js, and the popularity of React Native. Then I mentioned the good experience of applets, and I was slapped in the face for believing that applets were implemented in an RN-like way without much research.

When you first open the applet, you need to download the X5 WebView kernel and use uiAutomatorViewer to View the applet on the root phone. You can see the structure of the View on the right, which is obviously a WebView, but the class name can be changed. I wonder if Tencent is deliberately using the WebView name to confuse people (can I really be that boring)

X5 Debug: X5 Debug: X5 Debug: X5 Debug: X5 Debug Go to debugx5.qq.com and start Chrome Inspector in info. (SegmentFault for Android uses this kernel.) Then, after opening the widget, we connect to the computer, open the Chrome ://inspect page with Chrome, and see something like this

One of the things that Comes to mind when looking at Untitled and About: Blank is that it uses Server Render, which is HTML rendered on the Android client, rather than padding the data in a WebView (because that’s what I did). And then I’ll go ahead and click Inspect, and we can see the standard Chrome Dev Tools which is going to be really exciting for those of you who know the front end.

I wanted to switch to the Network Tab and see what resources were loaded. Using Location.reload () and Command + R didn’t make the miniprogram rerender. So wechat may have blocked the reload method (let me know if you find out how to reload it).

Later, when I loaded more sliders, I did not find any data generated in the Network, which proves that the data flow is not conducted in the WebView

To get a clearer picture, I exported UA

Mozilla / 5.0 (Linux; Android 7.1.1. Nexus 5X Build/NMF26Q AppleWebKit/537.36 (KHTML, Like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile MQQBrowser/ 6.9TBS /036906 Safari/537.36 MicroMessenger/6.5.3.980 NetType/WIFI Language/zh_CN

Here you can see that it uses the related modules MQQBrowser and TBS.

All right, that’s all for the preliminary analysis, and that’s enough for the face punch.

Performance optimization

My friends and I are curious about how Tencent optimizes the Webview experience to be so smooth, so we have the following guesses:

  1. Optimized in the Webview layer, removed code added for generality. (Kernel level)

  2. The Virtual DOM method is used to make every element rendered match the WebView, so as to avoid rendering other DOM (DOM layer) that may affect performance after user customization.

  3. Only limited-level script calls are provided (at the JS level).

What’s the advantage of this for the applet?

  1. Obviously, based on a mature Web, the availability and maturity is much higher than RN or WEEX, and it can be rolled out with little practice and low development costs.

  2. Small program download package is very natural, only the static file down, easy to plug and play, use up and go, do not need to register activities, do not need to hack.

  3. At the same time, the data is Native, which avoids cross-domain problems in the front end and becomes controllable at the same time.

  4. Using the original JS-SDK solution, the SDK solution is also mature.

Even so, it took a long time, but I’m sure it’s more than just a technical test. Of course, I don’t know much about products, so I dare not make other guesses.

At the end

Let’s talk about those programmers at the beginning. Some of them worry about Winter is coming every day and their jobs every day. They always have a lot of time to worry about themselves, but they can’t open a book, open Google and see the new world. They keep saying Android/iOS has no future. In fact, when they were forced not easy to learn the small program, will find programmers, is also a no prospects of the industry, because they only stand so high, has not thought of climbing.

Here, I encourage you not to forget self-learning and self-struggle friends, today there is a little bit of negative energy, I hope the friendliness will not drop too much, as long as you love learning, we are still good friends.

And of course, at the end:

Welcome to TalkWithMobile