LoginSignup
75

More than 5 years have passed since last update.

非同期じゃないXMLHttpRequestをメインスレッドで使うのはもうオワコンらしい

Last updated at Posted at 2015-05-21

弊社のとあるページにて、DeveloperToolsコンソールを開くと以下のようWarningなメッセージが出力されることを発見(確認したのは Google Chrome 43)。

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

メッセージからXMLHttpRequestを同期読み込みで行っているのが原因ってことなんだけど、いちおう詳細内容確認してみた。

該当セクションは以下。
https://xhr.spec.whatwg.org/#the-open()-method

引用。

Synchronous XMLHttpRequest outside of workers is in the process of being removed from the web platform as it has detrimental effects to the end user's experience. (This is a long process that takes many years.) Developers must not pass false for the async argument when the JavaScript global environment is a document environment. User agents are strongly encouraged to warn about such usage in developer tools and may experiment with throwing an InvalidAccessError exception when it occurs.

超絶意訳すると、

  • 同期読み込みをワーカー以外(タイトルにはメインスレッドと書いてみたが適切な表現なんだろう?)で行うのはユーザー体験を損なうからWeb標準から外されることになったよ
  • そのような使い方をした場合にDeveloperToolsの中で警告を出すし、実験的に例外を投げるようになるかもしれないよ

ってことなので、特段の理由があってあえてメインスレッドで同期読み込みしている場合は修正必須ってことですね。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
75