Chrome 和其他浏览器会放弃对同步 XMLHttpRequest 的支持吗?

Will Chrome and other browsers drop support for Synchronous XMLHttpRequest?

同步 XMLHttpRequest 正在弃用,这意味着最终将删除对它的支持,这是我在 Chrome 中收到的消息:

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.

所以,我的问题是主流浏览器(尤其是 Chrome)是否会放弃对同步 XMLHttpRequest 的支持?

更新:(最后更新于 2019 年 2 月)

  • Chrome 54 removes 微任务期间支持同步XHR 执行。
  • Chrome 80 removes 在页面关闭期间支持同步 XHR,其中企业用户可以使用策略标志解决问题,直到 Chrome 82.

恕我直言,现在(比 6 年前)最终删除此功能的可能性更高。一如既往,建议避免同步 XHR 的新用途,并抢先迁移现有的,因为浏览器可以选择在几个月的通知后删除它们。


我没有内幕消息,但这里有一些研究。

decision to deprecate was made in Feb 2014. Chrome declared it deprecated the same month but did not show a warning until Nov 2014. Firefox deprecated 2014 年 6 月 (Firefox 30)。

一般来说,Web 的重要功能需要时间才能迁移。例如,2015 年 4 月 Chrome deprecated NPAPI support in Sep 2013. It is disabled by default (Chrome 42),并计划于 2015 年 9 月完全删除。

在这种情况下,ExtJS still uses this feature for module loading. Other modules use it inside an unload event to ping the server, but beacon replacement technology is far from ready for prime time. There are some more 个引人注目的用例。

大约 2.5% of websites(更新:2017 年 10 月下降到 0.8%)仍在使用同步 XMLHttpRequest。它看起来不会很快消失。