Facebook’s open source browser contributions

Thanks to some powerful new technologies, web applications have come a long way in the past decade. But the performance of these web applications still lags behind that of their native counterparts…

Vladan Djeric
9 min readadvanced
--
View Original

Overview

The article discusses Facebook's contributions to improving web application performance through open-source projects aimed at enhancing the web platform. Key initiatives include the isInputPending API, JavaScript Self-Profiling API, and BinAST, which address issues related to JavaScript code size and web introspection APIs.

What You'll Learn

1

How to implement the isInputPending() API for better user input handling

2

Why retired instruction counts improve web performance benchmarking

3

How to utilize the JavaScript Self-Profiling API for performance optimization

4

Why BinAST can enhance JavaScript parsing efficiency

Prerequisites & Requirements

  • Understanding of JavaScript and web application performance concepts
  • Familiarity with browser development tools(optional)

Key Questions Answered

What are the main issues affecting web app performance compared to native apps?
Web applications face performance issues primarily due to the inability of current browsers to scale with large JavaScript codebases and the lack of access to system-level APIs. This results in overhead from parsing and JIT optimization, making web apps slower than their native counterparts.
How does the isInputPending() API improve JavaScript execution?
The isInputPending() API allows JavaScript tasks to check for pending user input events, enabling non-critical tasks to yield control of the event loop when necessary. This leads to improved responsiveness in web applications, particularly beneficial for frameworks like React and Angular.
What is the purpose of the JavaScript Self-Profiling API?
The JavaScript Self-Profiling API is designed to collect accurate execution stack traces with low CPU overhead, helping developers identify performance bottlenecks in their code. It allows for real-world data collection to better understand user experiences without requiring code changes.
What benefits does BinAST offer for JavaScript performance?
BinAST provides a binary encoding of JavaScript's abstract syntax tree, allowing engines to parse only the code that will be executed. This reduces parsing overhead and improves startup performance, particularly for large codebases with many unused functions.

Key Statistics & Figures

CPU time spent parsing JavaScript on Facebook.com
approximately 750 ms
This measurement highlights the significant overhead associated with JavaScript parsing during page load.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Frontend
Javascript
Used for web application development and performance optimization initiatives.
Encoding Format
Binast
Proposed to improve JavaScript parsing efficiency.
Browser
Chrome
Implemented the isInputPending() API and tested performance improvements.
Browser
Firefox Nightly
Implemented experimental BinAST support.

Key Actionable Insights

1
Implement the isInputPending() API to enhance user experience in web applications.
By allowing JavaScript to check for pending user inputs, developers can ensure that their applications remain responsive, especially during heavy processing tasks.
2
Utilize retired instruction counts for more reliable performance benchmarking.
This metric reduces noise in performance tests, allowing developers to reproduce results more accurately across different environments, which is crucial for identifying regressions.
3
Adopt the JavaScript Self-Profiling API to streamline performance optimization efforts.
This API helps developers quickly identify bottlenecks in real user environments, making it easier to address performance issues post-deployment.
4
Explore the benefits of BinAST to improve JavaScript loading times.
By implementing BinAST, developers can significantly reduce the parsing time for JavaScript, leading to faster application startup and better performance on lower-end devices.

Common Pitfalls

1
Failing to consider the performance implications of large JavaScript codebases can lead to slow web applications.
Without addressing the limitations of current web APIs and browser performance, developers may inadvertently create applications that are less responsive than their native counterparts.

Related Concepts

Web Performance Optimization
Javascript Execution And Profiling
Browser API Development
Comparative Analysis Of Web Vs. Native Applications