Getting rid of synchronous XHRs

Published on Updated on

We expect to remove support for synchronous use of XMLHTTPRequest() during page unloads in Chrome in version 88, scheduled to ship in January 2021.

Heads up! The XMLHttpRequest2 spec was recently changed to prohibit sending a synchronous request when XMLHttpRequest.responseType is set. The idea behind the change is to help mitigate further usage of synchronous xhrs wherever possible.

For example, the following code will now throw an INVALID_ACCESS_ERR in developer channel builds of Chrome and FF:

var xhr = new XMLHttpRequest();
xhr.responseType = 'arraybuffer';'GET', '/', false); // sync request

See WebKit Bug, Mozilla Bug

The ability to parse HTML has also been added to XMLHttpRequest but the caveat is that you can't use it unless you're sending an asynchronous request! See HTML in XMLHttpRequest.

Synchronous XHRs are bad for a number of reasons, but MSDN's blog post, "Why You Should Use XMLHttpRequest Asynchronously" has a great explanation of the issues.

This is a generally a great change for the web, but it has the potential to break some existing apps that were relying on synchronous behavior. Please look over your XHR code and update it ASAP to use asynchronous requests.

Updated on Improve article


HTML5 audio and the Web Audio API are BFFs


Web Audio FAQ

This site uses cookies to deliver and enhance the quality of its services and to analyze traffic. If you agree, cookies are also used to serve advertising and to personalize the content and advertisements that you see. Learn more about our use of cookies.