Facebook makes its first contribution to the browser API – TechCrunch



[ad_1]

Facebook today announced the first major contribution of the API to Google Chrome browser. With Google, The Facebook team has created an API proposal to bring code to the browser, a first for the company. The code, like much of Facebook's work on Web tools and standards, aims to make the user experience a little smoother and faster. In this case, it means shortening the time between clicking or typing and the browser reaction.

The first test of this new system will be launched with Chrome 74.

Typically, a browser's JavaScript engine processes code execution and momentarily pauses to see if there are any pending entry events to respond to. Because even modern JavaScript engines that run on multi-core machines are still essentially single-threaded, the engine can really only do one thing at a time. The trick therefore is to find the best way to combine the execution of the code with the search for events.

"Like many other sites, we are dealing with this problem by dividing the JavaScript into smaller blocks. While loading the page, we use a bit of JavaScript, then we give control to the browser, "says the Facebook team in the announcement of the day. "The browser can then check its input event queue and see if it has anything to say about the page. Then, the browser can return to the execution of the JavaScript blocks as and when they are added. "

However, each time the browser follows this cycle, checks for new events, processes them, and some extra time elapses. You do this too many times and the loading of the page slows down. But if you check the entries only at slower intervals, the user experience is degraded as the browser takes longer to react.

To solve this problem, Facebook engineers have created the isInputPending API, which eliminates this trade-off. The API, which Facebook has also brought to the W3C Web Performance Working Group, allows developers to check if entries are pending while their code is running.

With this, the code simply checks if there is something to react, without having to give the browser full control, then the JavaScript engine.

For the moment, this is just a test – and as developers need to embed it in their code, it will not automatically speed up your browser once Chrome 74 is launched. If the test succeeds, however, it is likely that developers will use it (and Facebook will certainly do it itself) and that other browser editors will also integrate it via their own engines.

"The process by which Chrome isInputPending is a new method of developing Web standards on Facebook," said the team. "We hope to continue to manage new APIs and strengthen our contributions to open source web browsers. Ultimately, we could potentially build this API directly in React's simultaneous mode so that developers can take full advantage of the API. In addition, isInputPending is now part of a larger effort to create web-based scheduling primitives. "

[ad_2]

Source link