IEInternals

A look at Internet Explorer from the inside out. @EricLaw left Microsoft in 2012, but was named an IE MVP in '13 & an IE userAgent (http://useragents.ie) in '14

Please don't make XHR run in synchronous mode

Please don't make XHR run in synchronous mode

  • Comments 6

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.

http://blogs.msdn.com/b/wer/archive/2011/08/03/why-you-should-use-xmlhttprequest-asynchronously.aspx

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.

  • 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

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

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

  • @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.

  • 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.

  • 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 window.open, I have to do things synchronously... And yes, the new window is a requirement.

    Regards, Michael

Page 1 of 1 (6 items)
Leave a Comment
  • Please add 5 and 8 and type the answer here:
  • Post