aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/performancepainttiming
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/performancepainttiming
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/performancepainttiming')
-rw-r--r--files/zh-cn/web/api/performancepainttiming/index.html130
1 files changed, 130 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/performancepainttiming/index.html b/files/zh-cn/web/api/performancepainttiming/index.html
new file mode 100644
index 0000000000..22be6268da
--- /dev/null
+++ b/files/zh-cn/web/api/performancepainttiming/index.html
@@ -0,0 +1,130 @@
+---
+title: PerformancePaintTiming
+slug: Web/API/PerformancePaintTiming
+tags:
+ - API
+ - Interface
+ - Paint Timing
+ - Performance Timeline API
+ - PerformancePaintTiming
+ - Web Performance
+ - 渲染时机
+ - 渲染监测
+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>是一个提供页面在构建过程中的“绘制”(也称“渲染”)时间点信息的接口。“绘制”是指将渲染树转换为页面上像素的过程。</p>
+
+<p>应用可以为名为“<code>paint</code>”的{{domxref("PerformanceEntry","performance entry 类型")}} 注册一个{{domxref("PerformanceObserver")}},然后观察者可以获取绘制相关的事件发生的时间。以此来帮你找出那些花费太多时间去绘制的区域,而后提升用户体验。</p>
+
+<p>{{InheritanceDiagram}}</p>
+
+<h2 id="属性">属性</h2>
+
+<p>这个接口没有属性,但是(为了"<code>paint</code>" {{domxref ("PerformanceEntry.entryType","performance entry 类型")}})通过一些限制和约束 扩展了以下{{domxref("PerformanceEntry")}}属性</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","timestamp")}}.</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) =&gt; {
+      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">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('Paint Timing','#sec-PerformancePaintTiming','PerformancePaintTiming')}}</td>
+ <td>{{Spec2('Paint Timing')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari (WebKit)</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatChrome(60)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatOpera(47)}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android Webview</th>
+ <th>Chrome for Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>Firefox OS</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatChrome(60)}}</td>
+ <td>{{CompatChrome(60)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatOperaMobile(47)}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>