{"id":10971,"date":"2023-09-15T23:58:22","date_gmt":"2023-09-15T15:58:22","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10971"},"modified":"2023-09-15T23:58:22","modified_gmt":"2023-09-15T15:58:22","slug":"html-elementtiming-attribute","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2023\/09\/html-elementtiming-attribute\/","title":{"rendered":"HTML elementtiming\u5c5e\u6027\u521d\u4f53\u9a8c\u8bb0\u5f55"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10971\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10971<\/a> \u946b\u7a7a\u95f4-\u946b\u751f\u6d3b<br \/>\n\u672c\u6587\u6b22\u8fce\u5206\u4eab\u4e0e\u805a\u5408\uff0c\u5168\u6587\u8f6c\u8f7d\u5c31\u4e0d\u5fc5\u4e86\uff0c\u5c0a\u91cd\u7248\u6743\uff0c\u5708\u5b50\u5c31\u8fd9\u4e48\u5927\uff0c\u82e5\u6025\u7528\u53ef\u4ee5\u8054\u7cfb\u6388\u6743\u3002<\/p>\n<p><script>window.wxShareImgUrl = 'https:\/\/www.zhangxinxu.com\/study\/image\/share\/202309-htmltiming.jpg';<\/script><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202309\/sleep-cover.jpg\" width=\"431\" height=\"277\" alt=\"\u5915\u9633\u5348\u4f11\" class=\"alignright clip thumb size-medium\" \/><\/p>\n<h3>\u4e00\u3001\u5f00\u573a\u603b\u8981\u6709\u4e2a\u6807\u9898<\/h3>\n<p>\u4e0a\u4e2a\u6708\u6709\u597d\u597d<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2023\/08\/js-performanceobserver-api\/\">\u7814\u7a76PerformanceObserver\u8fd9\u4e2a\u6027\u80fd\u76d1\u63a7\u76f8\u5173\u7684API<\/a>\u3002<\/p>\n<p>\u4e0d\u8fc7\uff0c\u73a9\u4e86\u4e00\u5708\u4e0b\u6765\uff0c\u6ca1\u6709\u627e\u5230\u7edf\u8ba1\u67d0\u4e2a\u56fe\u7247\u52a0\u8f7d\u65f6\u957f\uff0c\u6216\u8005\u67d0\u4e2a\u5143\u7d20\u6e32\u67d3\u65f6\u95f4\u7684\u5165\u53e3\uff0c\u96be\u9053\u662f\u81ea\u5df1\u9519\u8fc7\u4e86\u4ec0\u4e48\u4e86\u5417\uff1f<\/p>\n<p>\u563f\uff0c\u8fd8\u771f\u662f\u9519\u8fc7\u4e86\uff01<\/p>\n<p>\u6709\u4e9b\u51fa\u4e4e\u610f\u6599\uff0c\u660e\u660e\u662fPerformanceObserver API\u660e\u660e\u662f\u4e2aJS API\uff0c\u91cc\u9762\u7684\u65b9\u6cd5\u5565\u7684\uff0c\u4e5f\u90fd\u662fJS\u9a71\u52a8\u7684\uff0c\u7ed3\u679c\u7edf\u8ba1\u5143\u7d20\u7684\u6e32\u67d3\u548c\u52a0\u8f7d\u65f6\u957f\u5374\u9760\u7684\u662f\u4e00\u4e2aHTML\u5c5e\u6027\u2014\u2014elementtiming\u3002<\/p>\n<h3>\u4e8c\u3001\u4e86\u89e3elementtiming\u5c5e\u6027<\/h3>\n<p>elementtiming\u5c5e\u6027\u53ef\u4ee5\u8bbe\u7f6e\u5728\u4efb\u4f55\u6709\u56fe\u6587\u5185\u5bb9\u7684\u5143\u7d20\u4e0a\uff0c\u5305\u62ec<code>background-image<\/code>\u80cc\u666f\u56fe\uff0c\u5bf9\u4e86\uff0c\u8fd8\u6709\u89c6\u9891\u5143\u7d20\u3002<\/p>\n<p>\u76f8\u5bf9\u4e8e\u544a\u8bc9\u6d4f\u89c8\u5668\uff1a<\/p>\n<p>\u201c\u5582\uff0c\u6d4f\u89c8\u5668\u9171\uff0c\u8fd9\u51e0\u4e2a\u4eba\u8001\u5b50\u5f88\u611f\u5174\u8da3\uff0c\u4f60\u5e2e\u6211\u770b\u7d27\u4e86\uff0c\u591a\u591a\u5173\u6ce8\u4e0b\uff01\u201d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202309\/2023-9-15_113947.png\" width=\"256\" height=\"177\" alt=\"\u56fe\u7247\u793a\u610f\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u6b64\u65f6\uff0c\u6d4f\u89c8\u5668\u5c31\u4f1a\u8bb0\u4f4f\u8fd9\u4e9b\u5143\u7d20\u7684\u52a0\u8f7d\u65f6\u957f\uff0c\u6e32\u67d3\u65f6\u957f\u7b49\u5404\u79cd\u4fe1\u606f\u3002<\/p>\n<p>\u914d\u5408PerformanceObserver API\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u83b7\u5f97\u8fd9\u4e9b\u4fe1\u606f\u4e86\u3002<\/p>\n<h4>\u6848\u4f8b\u8bf4\u660e<\/h4>\n<p>\u5047\u8bbe\u9875\u9762\u4e0a\u6709\u4e0b\u9762\u4e24\u4e2aHTML\u5143\u7d20\u3002<\/p>\n<pre>&lt;img src=\"..\/202305\/book.jpg\" elementtiming=\"image\"&gt;\r\n\r\n&lt;p elementtiming=\"text\"&gt;\u6211\u662f\u4e00\u6bb5\u5185\u5bb9\u3002&lt;\/p&gt;<\/pre>\n<p>\u6b64\u65f6\uff0c\u6d4f\u89c8\u5668\u5c31\u4f1a\u91cd\u70b9\u5173\u6ce8\u6807\u5fd7\u91cf\u4e3aimage\u548ctext\u7684\u4e24\u4e2a\u5143\u7d20\u7684\u5143\u7d20\u65f6\u957f\u76f8\u5173\u4fe1\u606f\u3002<\/p>\n<p>\u4e8e\u662f\uff0c\u901a\u8fc7\u6267\u884c\u4e0b\u9762\u7684\u4ee3\u7801\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u83b7\u5f97\u3002<\/p>\n<pre>const observer = new PerformanceObserver(list => {\r\n  let entries = list.getEntries().forEach(function (entry) {\r\n     console.log(entry);\r\n  });\r\n});\r\nobserver.observe({ \r\n  entryTypes: ['element'] \r\n});<\/pre>\n<p>\u6bd4\u65b9\u8bf4\uff0c\u53ef\u80fd\u5c31\u4f1a\u662f\u5982\u4e0b\u56fe\u6240\u793a\u7684 Chrome \u63a7\u5236\u53f0\u8f93\u51fa\uff0c\u53ef\u4ee5\u770b\u5230\uff0c\u4e0d\u4ec5\u663e\u793a\u4e86\u5143\u7d20\u7684\u5c3a\u5bf8\u548c\u4f4d\u7f6e\u4fe1\u606f\uff0c\u4ec0\u4e48\u65f6\u5019\u5f00\u59cb\u6e32\u67d3\uff0c\u4ee5\u53ca\u52a0\u8f7d\u65f6\u957f\uff08\u56fe\u7247\u5143\u7d20\u6709\uff09\u90fd\u663e\u793a\u4e86\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202309\/2023-09-14_224059.png\" width=\"594\" height=\"680\" alt=\"\u8f93\u51fa\u7ed3\u679c\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u771f\u68d2\uff01<\/p>\n<p>\u4ee5\u540e\uff0c\u9047\u5230\u9875\u9762\u6e32\u67d3\u5361\u987f\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u7cbe\u786e\u77e5\u9053\u7a76\u7adf\u662f\u54ea\u4e2a\u5143\u7d20\u7684\u6e32\u67d3\u62d6\u4e86\u540e\u817f\u4e86\u3002<\/p>\n<p>\u4e0a\u9762\u7684\u6848\u4f8b\u6709\u6f14\u793a\u9875\u9762\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/202309\/html-elementtiming-demo.php\" rel=\"noopener\" target=\"_blank\">HTML elementtiming\u5c5e\u6027\u57fa\u672c\u4f7f\u7528demo<\/a><\/p>\n<h4>\u517c\u5bb9\u6027<\/h4>\n<p>elementtiming\u5c5e\u6027\u867d\u597d\uff0c\u4f46\u662f\u76ee\u524dSafari\u6d4f\u89c8\u5668\u5e76\u4e0d\u652f\u6301\uff0c\u54e6\uff0cno~<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202309\/2023-9-15_114917.png\" width=\"655\" height=\"320\" alt=\"\u517c\u5bb9\u6027\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u4e0d\u8fc7\u7ec6\u7ec6\u4e00\u60f3\uff0c\u6027\u80fd\u68c0\u6d4b\u4e0e\u6392\u67e5\u8fd9\u4e2a\u4e8b\u60c5\uff0c\u53ea\u8981\u6709\u4e00\u4e2a\u6d4f\u89c8\u5668\u652f\u6301\uff0c\u5176\u5b9e\u5c31\u8db3\u591f\u4e86\u3002<\/p>\n<p>\u5728Chrome\u4e0b\u6027\u80fd\u5dee\u7684\uff0c\u4e00\u822c\u5728Safari\u4e0b\u6027\u80fd\u4e5f\u5dee\u3002<\/p>\n<p>\u8fd9\u4e48\u4e00\u60f3\uff0c\u4e5f\u5c31\u91ca\u7136\u4e86\uff0c\u7528\u8d77\u6765\uff01<\/p>\n<h3>\u4e09\u3001\u603b\u662f\u9700\u8981\u4e2a\u7ed3\u8bed\u7684<\/h3>\n<p>\u8bf4\u5565\u5462\u3002<\/p>\n<p>\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684\u3002<\/p>\n<p>9\u6708\u4efd\u5f00\u59cb\uff0c\u5df2\u7ecf\u6162\u6162\u8fdb\u5165\u4e4b\u524d\u90a3\u79cd\u9ad8\u5f3a\u5ea6\u521b\u4f5c\u72b6\u6001\u4e86\u3002<\/p>\n<p>\u4e8b\u513f\u8fd8\u633a\u591a\uff0c\u56fd\u5e86\u5fc5\u987b\u8981\u597d\u597d\u5229\u7528\u8d77\u6765\u4e86\u3002<\/p>\n<p>\u4e0a\u6d77S3\u9ad8\u5ea6\u8fd9\u4e2a\u6708\u5e95\u8981\u901a\u8f66\u4e86\uff0c\u53bb\u5949\u8d24\u9493\u9c7c\u66f4\u65b9\u4fbf\u4e86\u3002<\/p>\n<p>\u597d\u4e86\uff0c\u6700\u540e\uff0c\u795d\u5927\u5bb6\u5468\u672b\u5feb\u4e50\u5427\u3002<\/p>\n<p>? \u2728 ? \u2728 <\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u6b22\u8fce\u5206\u4eab\uff0c\u52ff\u5168\u6587\u8f6c\u8f7d\uff0c\u5982\u679c\u5b9e\u5728\u559c\u6b22\uff0c\u53ef\u6536\u85cf\uff0c\u6c38\u4e0d\u8fc7\u671f\uff0c\u4e14\u4f1a\u53ca\u65f6\u66f4\u65b0\u77e5\u8bc6\u70b9\u53ca\u4fee\u6b63\u9519\u8bef\uff0c\u9605\u8bfb\u4f53\u9a8c\u4e5f\u66f4\u597d\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10971\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10971<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202309\/sleep-cover.jpg\" width=\"160\" height=\"103\" alt=\"\u5915\u9633\u5348\u4f11\" class=\"alignright size-medium\" loading=\"lazy\" \/><\/p>\n<p>\u81ea\u5df1\u4f53\u9a8c\u4e86\u4e0b\uff0c\u51fa\u4e4e\u610f\u6599\uff0cHTML elementtiming\u5c5e\u6027\u5728\u6027\u80fd\u76d1\u63a7\u8fd9\u5757\uff0c\u6bd4\u9884\u60f3\u7684\u8981\u5b9e\u7528\u7684\u591a\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1097],"tags":[1520,1944,9,1940,322],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10971"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=10971"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10971\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=10971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=10971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=10971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}