Please don’t make XHR run in synchronous mode

The Windows Error Reporting team reports that 8.4% of all hangs in IE9 in the past month are caused by XMLHttpRequest objects blocking the UI thread with a synchronous request.

If your page uses XHR in synchronous mode, your first thought should be "I'm doing something wrong."

For a live example of why you shouldn't do this, see my Synchronous XHR test page.

Comments (6)

  1. steveg says:

    If it's inherently dumb, add a warning to IE, might cut it a % or two. And annoy a bunch of users. Win some, lose some.

    [x] Enable Synchronous XMLHttpRequest Warning

  2. Unfortunately, the Mixed Content warning demonstrates the failure of that type of design.

  3. zzz says:

    Can't you remove the synchronous API for when IE is not set to use compatibility mode, or is it already done

  4. FremyCompany says:

    @zzz: No, it isn't done. And I thope they will never do that. The synchronous mode can prove itself very useful in a web worker, for example.

  5. says:

    How about a console warning if synchronous mode is used in the UI thread? It wouldn't be a great solution (especially since the console doesn't become available unless the F12 dev tools are already open), but it might curb its use somewhat.

  6. Michael says:

    There are valid use cases for this: E.g. Clicking a link wanting to show a pop-up populated by the server instead of opening the link's url in a new window. Unless, that is, there's an empty response (no data available). Then I want a new window. And since pop-up blocker block, I have to do things synchronously… And yes, the new window is a requirement.

    Regards, Michael

Skip to main content