Faster input events with Facebook’s first browser API contribution

UPDATE Nov. 19, 2020: As of Chrome 87, the IsInputPending API is now available without the origin trial. The latest API incorporates a number of updates we’ve made in response to feedback from the …

Nate Schloss
8 min readbeginner
--
View Original

Overview

The article discusses Facebook's contribution of the isInputPending API to improve user input responsiveness in web applications. It highlights the challenges of queueing time in JavaScript execution and how this API can help eliminate delays, enhancing the overall user experience.

What You'll Learn

1

How to use the isInputPending API to improve event responsiveness

2

Why queueing time affects user experience in web applications

3

When to yield control back to the browser during JavaScript execution

Prerequisites & Requirements

  • Basic understanding of JavaScript and web performance concepts

Key Questions Answered

What is the purpose of the isInputPending API?
The isInputPending API is designed to inform developers whether there are input events pending, allowing them to decide when to yield control back to the browser. This can help eliminate the trade-off between fast loading and fast event response, enhancing user experience.
How does the isInputPending API improve JavaScript execution time?
By hooking into Chrome’s compositor-side input queue, the isInputPending API allows developers to check for pending input events without blocking the main thread. This enables more efficient scheduling of JavaScript execution, leading to faster event responses.
What are the consequences of large JavaScript blocks on user input?
Large JavaScript blocks can cause significant delays in processing user input events because the browser queues these events until the entire block is executed. This can lead to frustrating user experiences, such as delayed feedback on clicks or keystrokes.
When was the isInputPending API made available in Chrome?
The isInputPending API became available without the origin trial as of Chrome 87, which was released in December 2020. This marked a significant step in improving web performance and user interaction responsiveness.

Technologies & Tools

Browser
Chrome
The isInputPending API was developed for use in the Chrome browser to improve input event handling.

Key Actionable Insights

1
Implement the isInputPending API in your web applications to enhance user interaction responsiveness.
By checking for pending input events, you can optimize your JavaScript execution flow, ensuring that user inputs are processed promptly, which is crucial for maintaining a smooth user experience.
2
Break down large JavaScript blocks into smaller chunks to improve event handling.
This approach allows the browser to process user input events more frequently, reducing queueing delays and enhancing the overall responsiveness of your web application.
3
Participate in the origin trial for the isInputPending API to provide feedback and influence its development.
Your insights can help shape the future of this API, ensuring it meets the needs of developers and enhances web performance standards.

Common Pitfalls

1
Failing to yield control back to the browser can lead to poor user experience due to delayed input processing.
This often happens when developers run large blocks of JavaScript without checking for pending input events, causing the browser to queue user interactions until the script execution is complete.

Related Concepts

Web Performance
Javascript Execution
User Input Handling