PerformanceElementTiming: loadTime プロパティ
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。
loadTime
は PerformanceElementTiming
インターフェイスの読み取り専用プロパティで、テキストに対しては常に 0
を返します。画像については画像リソースが読み込まれてから要素に装着されるまでの時間を返します。
値
DOMHighResTimeStamp
で、この要素の loadTime
です。テキストに対しては 0
です。
例
loadTime
をログ出力
この例では <img>
要素に elementtiming
属性を追加して監視しています。 PerformanceObserver
は "element"
型のパフォーマンス項目をすべて取得するために登録されます。オブザーバーが作成される前のデータにアクセスするには buffered
フラグを使用します。 entry.loadTime
を呼び出すと、画像要素の読み込み時間を返します。
html
<img
src="image.jpg"
alt="a nice image"
elementtiming="big-image"
id="myImage" />
js
const observer = new PerformanceObserver((list) => {
list.getEntries().forEach((entry) => {
if (entry.identifier === "big-image") {
console.log(entry.loadTime);
}
});
});
observer.observe({ type: "element", buffered: true });
仕様書
Specification |
---|
Element Timing API # ref-for-dom-performanceelementtiming-loadtime① |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
loadTime |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- Experimental. Expect behavior to change in the future.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.