9
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

window.performance.navigationが非推奨

Last updated at Posted at 2020-12-22

MDNのPerformanceNavigation.typeに記載の通り、次のソースコードはVSCode上で非推奨と提示される。

const isNavigate = window?.performance?.navigation?.type === 0;

PerformanceNavigationTimingの利用は正解ですが、具体的な使い方がよく分からなかった。

調べた結果、Performance.getEntriesByType()で次のように行ける。

const isNavigate = window?.performance?.getEntriesByType('navigation')[0].type === 'navigate';

window?.performance.getEntries()では全てのエントリーを調べられる。

参考記事

9
7
0

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
9
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?