--- title: PerformancePaintTiming slug: Web/API/PerformancePaintTiming tags: - API - PerformancePaintTiming - Web パフォーマンス - インターフェイス - パフォーマンスタイムライン API - ペイントタイミング - リファレンス translation_of: Web/API/PerformancePaintTiming --- <p>{{SeeCompatTable}}{{APIRef("Performance Timeline API")}}</p> <p><a href="/en-US/docs/Web/API/Paint Timing">Paint Timing</a> の <strong><code>PerformancePaintTiming</code></strong> インタフェースは、Web ページ構築中の "paint" ("render" とも呼ばれる) 操作に関するタイミング情報を提供します。「ペイント」とは、レンダリングツリーを画面上のピクセルに変換することです。</p> <p>アプリケーションは、"<code>paint</code>" {{domxref("PerformanceEntry","パフォーマンスエントリタイプ")}} に対して {{domxref("PerformanceObserver")}} を登録することができ、オブザーバーはペイントイベントが発生した時間を取得することができます。この情報を使用して、優れたユーザーエクスペリエンスを提供するのに時間がかかりすぎる領域を特定するのに役立ちます。</p> <p>{{InheritanceDiagram}}</p> <h2 id="プロパティ">プロパティ</h2> <p>このインタフェースにはプロパティはありませんが、次のようにプロパティを修飾および制約することで、次の {{domxref("PerformanceEntry")}} プロパティ ("<code>paint</code>"{{domxref ("PerformanceEntry.entryType","パフォーマンスエントリタイプ")}} 用) を拡張します。</p> <dl> <dt>{{domxref("PerformanceEntry.entryType")}}</dt> <dd>"<code>paint</code>" を返します。</dd> <dt>{{domxref("PerformanceEntry.name")}}</dt> <dd><code>"first-paint"</code> または <code>"first-contentful-paint"</code> を返します。</dd> <dt>{{domxref("PerformanceEntry.startTime")}}</dt> <dd>描画が行われたときに {{domxref("DOMHighResTimeStamp","タイムスタンプ")}} を返します。</dd> <dt>{{domxref("PerformanceEntry.duration")}}</dt> <dd>0 を返します。</dd> </dl> <h2 id="メソッド">メソッド</h2> <p>このインターフェイスにはメソッドがありません。</p> <h2 id="例">例</h2> <pre class="brush: js">function showPaintTimings() { if (window.performance) { let performance = window.performance; let performanceEntries = performance.getEntriesByType('paint'); performanceEntries.forEach( (performanceEntry, i, entries) => { console.log("The time to " + performanceEntry.name + " was " + performanceEntry.startTime + " milliseconds."); }); } else { console.log('Performance timing isn\'t supported.'); } }</pre> <p>上記のコードは、次のようなコンソール出力を生成します。</p> <pre>The time to first-paint was 2785.915 milliseconds. The time to first-contentful-paint was 2787.460 milliseconds.</pre> <h2 id="仕様">仕様</h2> <table class="standard-table"> <tbody> <tr> <th scope="col">仕様書</th> <th scope="col">ステータス</th> <th scope="col">コメント</th> </tr> <tr> <td>{{SpecName('Paint Timing','#sec-PerformancePaintTiming','PerformancePaintTiming')}}</td> <td>{{Spec2('Paint Timing')}}</td> <td>初期定義</td> </tr> </tbody> </table> <h2 id="ブラウザの互換性">ブラウザの互換性</h2> <div class="hidden">このページの互換性テーブルは構造化データから生成されます。データに貢献したい場合は <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックして、プルリクエストを送ってください。</div> <p>{{Compat("api.PerformancePaintTiming")}}</p>