{"id":2636,"date":"2020-04-14T20:50:10","date_gmt":"2020-04-14T12:50:10","guid":{"rendered":"http:\/\/www.yuguoxy.com\/geekhome\/?p=2636"},"modified":"2020-04-14T20:50:10","modified_gmt":"2020-04-14T12:50:10","slug":"%e4%bd%a0%e7%9c%9f%e7%9a%84%e4%ba%86%e8%a7%a3%e5%9b%9e%e6%b5%81%e5%92%8c%e9%87%8d%e7%bb%98%e5%90%97","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=2636","title":{"rendered":"\u4f60\u771f\u7684\u4e86\u89e3\u56de\u6d41\u548c\u91cd\u7ed8\u5417"},"content":{"rendered":"<p>\u56de\u6d41\u548c\u91cd\u7ed8\u53ef\u4ee5\u8bf4\u662f\u6bcf\u4e00\u4e2aweb\u5f00\u53d1\u8005\u90fd\u7ecf\u5e38\u542c\u5230\u7684\u4e24\u4e2a\u8bcd\u8bed\uff0c\u6211\u4e5f\u4e0d\u4f8b\u5916\uff0c\u53ef\u662f\u6211\u4e4b\u524d\u4e00\u76f4\u4e0d\u662f\u5f88\u6e05\u695a\u8fd9\u4e24\u6b65\u5177\u4f53\u505a\u4e86\u4ec0\u4e48\u4e8b\u60c5\u3002\u6700\u8fd1\u7531\u4e8e\u90e8\u95e8\u5185\u90e8\u8981\u505a\u5206\u4eab\uff0c\u6240\u4ee5\u5bf9\u5176\u8fdb\u884c\u4e86\u4e00\u4e9b\u7814\u7a76\uff0c\u770b\u4e86\u4e00\u4e9b\u535a\u5ba2\u548c\u4e66\u7c4d\uff0c\u6574\u7406\u4e86\u4e00\u4e9b\u5185\u5bb9\u5e76\u4e14\u7ed3\u5408\u4e00\u4e9b\u4f8b\u5b50\uff0c\u5199\u4e86\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5e0c\u671b\u53ef\u4ee5\u5e2e\u52a9\u5230\u5927\u5bb6\u3002<\/p>\n<h2 id=\"item-1\">\u6d4f\u89c8\u5668\u7684\u6e32\u67d3\u8fc7\u7a0b<\/h2>\n<p>\u672c\u6587\u5148\u4ece\u6d4f\u89c8\u5668\u7684\u6e32\u67d3\u8fc7\u7a0b\u6765\u4ece\u5934\u5230\u5c3e\u7684\u8bb2\u89e3\u4e00\u4e0b\u56de\u6d41\u91cd\u7ed8\uff0c\u5982\u679c\u5927\u5bb6\u60f3\u76f4\u63a5\u770b\u5982\u4f55\u51cf\u5c11\u56de\u6d41\u548c\u91cd\u7ed8\uff0c\u53ef\u4ee5\u8df3\u5230\u540e\u9762\u3002\uff08\u8fd9\u4e2a\u6e32\u67d3\u8fc7\u7a0b\u6765\u81ea<a href=\"https:\/\/developers.google.com\/web\/fundamentals\/performance\/critical-rendering-path\/render-tree-construction?hl=zh-cn\" target=\"_blank\" rel=\"nofollow noreferrer\">MDN<\/a>\uff09<\/p>\n<p><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/4088852130-5afbe6c95934b_articlex.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2637\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/4088852130-5afbe6c95934b_articlex.png\" alt=\"4088852130-5afbe6c95934b_articlex\" width=\"624\" height=\"289\" \/><\/a><\/p>\n<p>\u4ece\u4e0a\u9762\u8fd9\u4e2a\u56fe\u4e0a\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0c\u6d4f\u89c8\u5668\u6e32\u67d3\u8fc7\u7a0b\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u89e3\u6790HTML\uff0c\u751f\u6210DOM\u6811\uff0c\u89e3\u6790CSS\uff0c\u751f\u6210CSSOM\u6811<\/li>\n<li>\u5c06DOM\u6811\u548cCSSOM\u6811\u7ed3\u5408\uff0c\u751f\u6210\u6e32\u67d3\u6811(Render Tree)<\/li>\n<li>Layout(\u56de\u6d41):\u6839\u636e\u751f\u6210\u7684\u6e32\u67d3\u6811\uff0c\u8fdb\u884c\u56de\u6d41(Layout)\uff0c\u5f97\u5230\u8282\u70b9\u7684\u51e0\u4f55\u4fe1\u606f\uff08\u4f4d\u7f6e\uff0c\u5927\u5c0f\uff09<\/li>\n<li>Painting(\u91cd\u7ed8):\u6839\u636e\u6e32\u67d3\u6811\u4ee5\u53ca\u56de\u6d41\u5f97\u5230\u7684\u51e0\u4f55\u4fe1\u606f\uff0c\u5f97\u5230\u8282\u70b9\u7684\u7edd\u5bf9\u50cf\u7d20<\/li>\n<li>Display:\u5c06\u50cf\u7d20\u53d1\u9001\u7ed9GPU\uff0c\u5c55\u793a\u5728\u9875\u9762\u4e0a\u3002\uff08\u8fd9\u4e00\u6b65\u5176\u5b9e\u8fd8\u6709\u5f88\u591a\u5185\u5bb9\uff0c\u6bd4\u5982\u4f1a\u5728GPU\u5c06\u591a\u4e2a\u5408\u6210\u5c42\u5408\u5e76\u4e3a\u540c\u4e00\u4e2a\u5c42\uff0c\u5e76\u5c55\u793a\u5728\u9875\u9762\u4e2d\u3002\u800ccss3\u786c\u4ef6\u52a0\u901f\u7684\u539f\u7406\u5219\u662f\u65b0\u5efa\u5408\u6210\u5c42\uff0c\u8fd9\u91cc\u6211\u4eec\u4e0d\u5c55\u5f00\uff0c\u4e4b\u540e\u6709\u673a\u4f1a\u4f1a\u5199\u4e00\u7bc7\u535a\u5ba2\uff09<\/li>\n<\/ol>\n<p>\u6e32\u67d3\u8fc7\u7a0b\u770b\u8d77\u6765\u5f88\u7b80\u5355\uff0c\u8ba9\u6211\u4eec\u6765\u5177\u4f53\u4e86\u89e3\u4e0b\u6bcf\u4e00\u6b65\u5177\u4f53\u505a\u4e86\u4ec0\u4e48\u3002<\/p>\n<h3 id=\"item-1-1\">\u751f\u6210\u6e32\u67d3\u6811<\/h3>\n<p><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/4223770356-5abdb235cdd7d_articlex.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2638\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/4223770356-5abdb235cdd7d_articlex.png\" alt=\"4223770356-5abdb235cdd7d_articlex\" width=\"800\" height=\"374\" \/><\/a><\/p>\n<p>\u4e3a\u4e86\u6784\u5efa\u6e32\u67d3\u6811\uff0c\u6d4f\u89c8\u5668\u4e3b\u8981\u5b8c\u6210\u4e86\u4ee5\u4e0b\u5de5\u4f5c\uff1a<\/p>\n<ol>\n<li>\u4eceDOM\u6811\u7684\u6839\u8282\u70b9\u5f00\u59cb\u904d\u5386\u6bcf\u4e2a\u53ef\u89c1\u8282\u70b9\u3002<\/li>\n<li>\u5bf9\u4e8e\u6bcf\u4e2a\u53ef\u89c1\u7684\u8282\u70b9\uff0c\u627e\u5230CSSOM\u6811\u4e2d\u5bf9\u5e94\u7684\u89c4\u5219\uff0c\u5e76\u5e94\u7528\u5b83\u4eec\u3002<\/li>\n<li>\u6839\u636e\u6bcf\u4e2a\u53ef\u89c1\u8282\u70b9\u4ee5\u53ca\u5176\u5bf9\u5e94\u7684\u6837\u5f0f\uff0c\u7ec4\u5408\u751f\u6210\u6e32\u67d3\u6811\u3002<\/li>\n<\/ol>\n<p>\u7b2c\u4e00\u6b65\u4e2d\uff0c\u65e2\u7136\u8bf4\u5230\u4e86\u8981\u904d\u5386\u53ef\u89c1\u7684\u8282\u70b9\uff0c\u90a3\u4e48\u6211\u4eec\u5f97\u5148\u77e5\u9053\uff0c\u4ec0\u4e48\u8282\u70b9\u662f\u4e0d\u53ef\u89c1\u7684\u3002\u4e0d\u53ef\u89c1\u7684\u8282\u70b9\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\u4e00\u4e9b\u4e0d\u4f1a\u6e32\u67d3\u8f93\u51fa\u7684\u8282\u70b9\uff0c\u6bd4\u5982script\u3001meta\u3001link\u7b49\u3002<\/li>\n<li>\u4e00\u4e9b\u901a\u8fc7css\u8fdb\u884c\u9690\u85cf\u7684\u8282\u70b9\u3002\u6bd4\u5982display:none\u3002\u6ce8\u610f\uff0c\u5229\u7528visibility\u548copacity\u9690\u85cf\u7684\u8282\u70b9\uff0c\u8fd8\u662f\u4f1a\u663e\u793a\u5728\u6e32\u67d3\u6811\u4e0a\u7684\u3002\u53ea\u6709display:none\u7684\u8282\u70b9\u624d\u4e0d\u4f1a\u663e\u793a\u5728\u6e32\u67d3\u6811\u4e0a\u3002<\/li>\n<\/ul>\n<p><strong>\u6ce8\u610f\uff1a\u6e32\u67d3\u6811\u53ea\u5305\u542b\u53ef\u89c1\u7684\u8282\u70b9<\/strong><\/p>\n<h3 id=\"item-1-2\">\u56de\u6d41<\/h3>\n<p>\u524d\u9762\u6211\u4eec\u901a\u8fc7\u6784\u9020\u6e32\u67d3\u6811\uff0c\u6211\u4eec\u5c06\u53ef\u89c1DOM\u8282\u70b9\u4ee5\u53ca\u5b83\u5bf9\u5e94\u7684\u6837\u5f0f\u7ed3\u5408\u8d77\u6765\uff0c\u53ef\u662f\u6211\u4eec\u8fd8\u9700\u8981\u8ba1\u7b97\u5b83\u4eec\u5728\u8bbe\u5907\u89c6\u53e3(viewport)\u5185\u7684\u786e\u5207\u4f4d\u7f6e\u548c\u5927\u5c0f\uff0c\u8fd9\u4e2a\u8ba1\u7b97\u7684\u9636\u6bb5\u5c31\u662f\u56de\u6d41\u3002<\/p>\n<p>\u4e3a\u4e86\u5f04\u6e05\u6bcf\u4e2a\u5bf9\u8c61\u5728\u7f51\u7ad9\u4e0a\u7684\u786e\u5207\u5927\u5c0f\u548c\u4f4d\u7f6e\uff0c\u6d4f\u89c8\u5668\u4ece\u6e32\u67d3\u6811\u7684\u6839\u8282\u70b9\u5f00\u59cb\u904d\u5386\uff0c\u6211\u4eec\u53ef\u4ee5\u4ee5\u4e0b\u9762\u8fd9\u4e2a\u5b9e\u4f8b\u6765\u8868\u793a\uff1a<\/p>\n<pre class=\"xml hljs\"><code class=\"html\"><span class=\"hljs-meta\">&lt;!DOCTYPE <span class=\"hljs-meta-keyword\">html<\/span>&gt;<\/span>\r\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">html<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">head<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">meta<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\">\"viewport\"<\/span> <span class=\"hljs-attr\">content<\/span>=<span class=\"hljs-string\">\"width=device-width,initial-scale=1\"<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">title<\/span>&gt;<\/span>Critial Path: Hello world!<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">title<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">head<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">body<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">style<\/span>=<span class=\"hljs-string\">\"width: 50%\"<\/span>&gt;<\/span>\r\n      <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">style<\/span>=<span class=\"hljs-string\">\"width: 50%\"<\/span>&gt;<\/span>Hello world!<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\r\n  <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">body<\/span>&gt;<\/span>\r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">html<\/span>&gt;<\/span><\/code><\/pre>\n<p>\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0c\u7b2c\u4e00\u4e2adiv\u5c06\u8282\u70b9\u7684\u663e\u793a\u5c3a\u5bf8\u8bbe\u7f6e\u4e3a\u89c6\u53e3\u5bbd\u5ea6\u768450%\uff0c\u7b2c\u4e8c\u4e2adiv\u5c06\u5176\u5c3a\u5bf8\u8bbe\u7f6e\u4e3a\u7236\u8282\u70b9\u768450%\u3002\u800c\u5728\u56de\u6d41\u8fd9\u4e2a\u9636\u6bb5\uff0c\u6211\u4eec\u5c31\u9700\u8981\u6839\u636e\u89c6\u53e3\u5177\u4f53\u7684\u5bbd\u5ea6\uff0c\u5c06\u5176\u8f6c\u4e3a\u5b9e\u9645\u7684\u50cf\u7d20\u503c\u3002\uff08\u5982\u4e0b\u56fe\uff09<\/p>\n<p><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/1189033455-5aec8b9d3bcb2_articlex.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2641\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/1189033455-5aec8b9d3bcb2_articlex.png\" alt=\"1189033455-5aec8b9d3bcb2_articlex\" width=\"616\" height=\"281\" srcset=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/1189033455-5aec8b9d3bcb2_articlex.png 616w, https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/1189033455-5aec8b9d3bcb2_articlex-350x160.png 350w\" sizes=\"(max-width: 616px) 100vw, 616px\" \/><\/a><\/p>\n<h3 id=\"item-1-3\">\u91cd\u7ed8<\/h3>\n<p>\u6700\u7ec8\uff0c\u6211\u4eec\u901a\u8fc7\u6784\u9020\u6e32\u67d3\u6811\u548c\u56de\u6d41\u9636\u6bb5\uff0c\u6211\u4eec\u77e5\u9053\u4e86\u54ea\u4e9b\u8282\u70b9\u662f\u53ef\u89c1\u7684\uff0c\u4ee5\u53ca\u53ef\u89c1\u8282\u70b9\u7684\u6837\u5f0f\u548c\u5177\u4f53\u7684\u51e0\u4f55\u4fe1\u606f(\u4f4d\u7f6e\u3001\u5927\u5c0f)\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u53ef\u4ee5\u5c06\u6e32\u67d3\u6811\u7684\u6bcf\u4e2a\u8282\u70b9\u90fd\u8f6c\u6362\u4e3a\u5c4f\u5e55\u4e0a\u7684\u5b9e\u9645\u50cf\u7d20\uff0c\u8fd9\u4e2a\u9636\u6bb5\u5c31\u53eb\u505a\u91cd\u7ed8\u8282\u70b9\u3002<\/p>\n<p>\u65e2\u7136\u77e5\u9053\u4e86\u6d4f\u89c8\u5668\u7684\u6e32\u67d3\u8fc7\u7a0b\u540e\uff0c\u6211\u4eec\u5c31\u6765\u63a2\u8ba8\u4e0b\uff0c\u4f55\u65f6\u4f1a\u53d1\u751f\u56de\u6d41\u91cd\u7ed8\u3002<\/p>\n<h2 id=\"item-2\">\u4f55\u65f6\u53d1\u751f\u56de\u6d41\u91cd\u7ed8<\/h2>\n<p>\u6211\u4eec\u524d\u9762\u77e5\u9053\u4e86\uff0c\u56de\u6d41\u8fd9\u4e00\u9636\u6bb5\u4e3b\u8981\u662f\u8ba1\u7b97\u8282\u70b9\u7684\u4f4d\u7f6e\u548c\u51e0\u4f55\u4fe1\u606f\uff0c\u90a3\u4e48\u5f53\u9875\u9762\u5e03\u5c40\u548c\u51e0\u4f55\u4fe1\u606f\u53d1\u751f\u53d8\u5316\u7684\u65f6\u5019\uff0c\u5c31\u9700\u8981\u56de\u6d41\u3002\u6bd4\u5982\u4ee5\u4e0b\u60c5\u51b5\uff1a<\/p>\n<ul>\n<li>\u6dfb\u52a0\u6216\u5220\u9664\u53ef\u89c1\u7684DOM\u5143\u7d20<\/li>\n<li>\u5143\u7d20\u7684\u4f4d\u7f6e\u53d1\u751f\u53d8\u5316<\/li>\n<li>\u5143\u7d20\u7684\u5c3a\u5bf8\u53d1\u751f\u53d8\u5316\uff08\u5305\u62ec\u5916\u8fb9\u8ddd\u3001\u5185\u8fb9\u6846\u3001\u8fb9\u6846\u5927\u5c0f\u3001\u9ad8\u5ea6\u548c\u5bbd\u5ea6\u7b49\uff09<\/li>\n<li>\u5185\u5bb9\u53d1\u751f\u53d8\u5316\uff0c\u6bd4\u5982\u6587\u672c\u53d8\u5316\u6216\u56fe\u7247\u88ab\u53e6\u4e00\u4e2a\u4e0d\u540c\u5c3a\u5bf8\u7684\u56fe\u7247\u6240\u66ff\u4ee3\u3002<\/li>\n<li>\u9875\u9762\u4e00\u5f00\u59cb\u6e32\u67d3\u7684\u65f6\u5019\uff08\u8fd9\u80af\u5b9a\u907f\u514d\u4e0d\u4e86\uff09<\/li>\n<li>\u6d4f\u89c8\u5668\u7684\u7a97\u53e3\u5c3a\u5bf8\u53d8\u5316\uff08\u56e0\u4e3a\u56de\u6d41\u662f\u6839\u636e\u89c6\u53e3\u7684\u5927\u5c0f\u6765\u8ba1\u7b97\u5143\u7d20\u7684\u4f4d\u7f6e\u548c\u5927\u5c0f\u7684\uff09<\/li>\n<\/ul>\n<p><strong>\u6ce8\u610f\uff1a\u56de\u6d41\u4e00\u5b9a\u4f1a\u89e6\u53d1\u91cd\u7ed8\uff0c\u800c\u91cd\u7ed8\u4e0d\u4e00\u5b9a\u4f1a\u56de\u6d41<\/strong><\/p>\n<p>\u6839\u636e\u6539\u53d8\u7684\u8303\u56f4\u548c\u7a0b\u5ea6\uff0c\u6e32\u67d3\u6811\u4e2d\u6216\u5927\u6216\u5c0f\u7684\u90e8\u5206\u9700\u8981\u91cd\u65b0\u8ba1\u7b97\uff0c\u6709\u4e9b\u6539\u53d8\u4f1a\u89e6\u53d1\u6574\u4e2a\u9875\u9762\u7684\u91cd\u6392\uff0c\u6bd4\u5982\uff0c\u6eda\u52a8\u6761\u51fa\u73b0\u7684\u65f6\u5019\u6216\u8005\u4fee\u6539\u4e86\u6839\u8282\u70b9\u3002<\/p>\n<h2 id=\"item-3\">\u6d4f\u89c8\u5668\u7684\u4f18\u5316\u673a\u5236<\/h2>\n<p>\u73b0\u4ee3\u7684\u6d4f\u89c8\u5668\u90fd\u662f\u5f88\u806a\u660e\u7684\uff0c\u7531\u4e8e\u6bcf\u6b21\u91cd\u6392\u90fd\u4f1a\u9020\u6210\u989d\u5916\u7684\u8ba1\u7b97\u6d88\u8017\uff0c\u56e0\u6b64\u5927\u591a\u6570\u6d4f\u89c8\u5668\u90fd\u4f1a\u901a\u8fc7\u961f\u5217\u5316\u4fee\u6539\u5e76\u6279\u91cf\u6267\u884c\u6765\u4f18\u5316\u91cd\u6392\u8fc7\u7a0b\u3002\u6d4f\u89c8\u5668\u4f1a\u5c06\u4fee\u6539\u64cd\u4f5c\u653e\u5165\u5230\u961f\u5217\u91cc\uff0c\u76f4\u5230\u8fc7\u4e86\u4e00\u6bb5\u65f6\u95f4\u6216\u8005\u64cd\u4f5c\u8fbe\u5230\u4e86\u4e00\u4e2a\u9608\u503c\uff0c\u624d\u6e05\u7a7a\u961f\u5217\u3002\u4f46\u662f\uff01<strong>\u5f53\u4f60\u83b7\u53d6\u5e03\u5c40\u4fe1\u606f\u7684\u64cd\u4f5c\u7684\u65f6\u5019\uff0c\u4f1a\u5f3a\u5236\u961f\u5217\u5237\u65b0<\/strong>\uff0c\u6bd4\u5982\u5f53\u4f60\u8bbf\u95ee\u4ee5\u4e0b\u5c5e\u6027\u6216\u8005\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>offsetTop\u3001offsetLeft\u3001offsetWidth\u3001offsetHeight<\/li>\n<li>scrollTop\u3001scrollLeft\u3001scrollWidth\u3001scrollHeight<\/li>\n<li>clientTop\u3001clientLeft\u3001clientWidth\u3001clientHeight<\/li>\n<li>getComputedStyle()<\/li>\n<li>getBoundingClientRect<\/li>\n<li>\u5177\u4f53\u53ef\u4ee5\u8bbf\u95ee\u8fd9\u4e2a\u7f51\u7ad9\uff1a<a href=\"https:\/\/gist.github.com\/paulirish\/5d52fb081b3570c81e3a\" target=\"_blank\" rel=\"nofollow noreferrer\">https:\/\/gist.github.com\/pauli&#8230;<\/a><button class=\"badge badge-light preview\" data-url=\"paulirish\" data-param=\"5d52fb081b3570c81e3a\" data-typeid=\"3\">\u70b9\u51fb\u9884\u89c8<\/button><\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c5e\u6027\u548c\u65b9\u6cd5\u90fd\u9700\u8981\u8fd4\u56de\u6700\u65b0\u7684\u5e03\u5c40\u4fe1\u606f\uff0c\u56e0\u6b64\u6d4f\u89c8\u5668\u4e0d\u5f97\u4e0d\u6e05\u7a7a\u961f\u5217\uff0c\u89e6\u53d1\u56de\u6d41\u91cd\u7ed8\u6765\u8fd4\u56de\u6b63\u786e\u7684\u503c\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u5728\u4fee\u6539\u6837\u5f0f\u7684\u65f6\u5019\uff0c<strong>\u6700\u597d\u907f\u514d\u4f7f\u7528\u4e0a\u9762\u5217\u51fa\u7684\u5c5e\u6027\uff0c\u4ed6\u4eec\u90fd\u4f1a\u5237\u65b0\u6e32\u67d3\u961f\u5217\u3002<\/strong>\u5982\u679c\u8981\u4f7f\u7528\u5b83\u4eec\uff0c\u6700\u597d\u5c06\u503c\u7f13\u5b58\u8d77\u6765\u3002<\/p>\n<h2 id=\"item-4\">\u51cf\u5c11\u56de\u6d41\u548c\u91cd\u7ed8<\/h2>\n<p>\u597d\u4e86\uff0c\u5230\u4e86\u6211\u4eec\u4eca\u5929\u7684\u91cd\u5934\u620f\uff0c\u524d\u9762\u8bf4\u4e86\u8fd9\u4e48\u591a\u80cc\u666f\u548c\u7406\u8bba\u77e5\u8bc6\uff0c\u63a5\u4e0b\u6765\u8ba9\u6211\u4eec\u8c08\u8c08\u5982\u4f55\u51cf\u5c11\u56de\u6d41\u548c\u91cd\u7ed8\u3002<\/p>\n<h3 id=\"item-4-4\">\u6700\u5c0f\u5316\u91cd\u7ed8\u548c\u91cd\u6392<\/h3>\n<p>\u7531\u4e8e\u91cd\u7ed8\u548c\u91cd\u6392\u53ef\u80fd\u4ee3\u4ef7\u6bd4\u8f83\u6602\u8d35\uff0c\u56e0\u6b64\u6700\u597d\u5c31\u662f\u53ef\u4ee5\u51cf\u5c11\u5b83\u7684\u53d1\u751f\u6b21\u6570\u3002\u4e3a\u4e86\u51cf\u5c11\u53d1\u751f\u6b21\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u5408\u5e76\u591a\u6b21\u5bf9DOM\u548c\u6837\u5f0f\u7684\u4fee\u6539\uff0c\u7136\u540e\u4e00\u6b21\u5904\u7406\u6389\u3002\u8003\u8651\u8fd9\u4e2a\u4f8b\u5b50<\/p>\n<pre class=\"javascript hljs\"><code class=\"javascript\"><span class=\"hljs-keyword\">const<\/span> el = <span class=\"hljs-built_in\">document<\/span>.getElementById(<span class=\"hljs-string\">'test'<\/span>);\r\nel.style.padding = <span class=\"hljs-string\">'5px'<\/span>;\r\nel.style.borderLeft = <span class=\"hljs-string\">'1px'<\/span>;\r\nel.style.borderRight = <span class=\"hljs-string\">'2px'<\/span>;<\/code><\/pre>\n<p>\u4f8b\u5b50\u4e2d\uff0c\u6709\u4e09\u4e2a\u6837\u5f0f\u5c5e\u6027\u88ab\u4fee\u6539\u4e86\uff0c\u6bcf\u4e00\u4e2a\u90fd\u4f1a\u5f71\u54cd\u5143\u7d20\u7684\u51e0\u4f55\u7ed3\u6784\uff0c\u5f15\u8d77\u56de\u6d41\u3002\u5f53\u7136\uff0c\u5927\u90e8\u5206\u73b0\u4ee3\u6d4f\u89c8\u5668\u90fd\u5bf9\u5176\u505a\u4e86\u4f18\u5316\uff0c\u56e0\u6b64\uff0c\u53ea\u4f1a\u89e6\u53d1\u4e00\u6b21\u91cd\u6392\u3002\u4f46\u662f\u5982\u679c\u5728\u65e7\u7248\u7684\u6d4f\u89c8\u5668\u6216\u8005\u5728\u4e0a\u9762\u4ee3\u7801\u6267\u884c\u7684\u65f6\u5019\uff0c\u6709\u5176\u4ed6\u4ee3\u7801\u8bbf\u95ee\u4e86\u5e03\u5c40\u4fe1\u606f(\u4e0a\u6587\u4e2d\u7684\u4f1a\u89e6\u53d1\u56de\u6d41\u7684\u5e03\u5c40\u4fe1\u606f)\uff0c\u90a3\u4e48\u5c31\u4f1a\u5bfc\u81f4\u4e09\u6b21\u91cd\u6392\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u6211\u4eec\u53ef\u4ee5\u5408\u5e76\u6240\u6709\u7684\u6539\u53d8\u7136\u540e\u4f9d\u6b21\u5904\u7406\uff0c\u6bd4\u5982\u6211\u4eec\u53ef\u4ee5\u91c7\u53d6\u4ee5\u4e0b\u7684\u65b9\u5f0f\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528cssText\n<pre class=\"javascript hljs\"><code class=\"javascript\"><span class=\"hljs-keyword\">const<\/span> el = <span class=\"hljs-built_in\">document<\/span>.getElementById(<span class=\"hljs-string\">'test'<\/span>);\r\nel.style.cssText += <span class=\"hljs-string\">'border-left: 1px; border-right: 2px; padding: 5px;'<\/span>;<\/code><\/pre>\n<\/li>\n<li>\u4fee\u6539CSS\u7684class\n<pre class=\"javascript hljs\"><code class=\"javascript\"><span class=\"hljs-keyword\">const<\/span> el = <span class=\"hljs-built_in\">document<\/span>.getElementById(<span class=\"hljs-string\">'test'<\/span>);\r\nel.className += <span class=\"hljs-string\">' active'<\/span>;<\/code><\/pre>\n<\/li>\n<\/ul>\n<h3 id=\"item-4-5\">\u6279\u91cf\u4fee\u6539DOM<\/h3>\n<p>\u5f53\u6211\u4eec\u9700\u8981\u5bf9DOM\u5bf9\u4e00\u7cfb\u5217\u4fee\u6539\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u51cf\u5c11\u56de\u6d41\u91cd\u7ed8\u6b21\u6570\uff1a<\/p>\n<ol>\n<li>\u4f7f\u5143\u7d20\u8131\u79bb\u6587\u6863\u6d41<\/li>\n<li>\u5bf9\u5176\u8fdb\u884c\u591a\u6b21\u4fee\u6539<\/li>\n<li>\u5c06\u5143\u7d20\u5e26\u56de\u5230\u6587\u6863\u4e2d\u3002<\/li>\n<\/ol>\n<p>\u8be5\u8fc7\u7a0b\u7684\u7b2c\u4e00\u6b65\u548c\u7b2c\u4e09\u6b65\u53ef\u80fd\u4f1a\u5f15\u8d77\u56de\u6d41\uff0c\u4f46\u662f\u7ecf\u8fc7\u7b2c\u4e00\u6b65\u4e4b\u540e\uff0c\u5bf9DOM\u7684\u6240\u6709\u4fee\u6539\u90fd\u4e0d\u4f1a\u5f15\u8d77\u56de\u6d41\uff0c\u56e0\u4e3a\u5b83\u5df2\u7ecf\u4e0d\u5728\u6e32\u67d3\u6811\u4e86\u3002<\/p>\n<p>\u6709\u4e09\u79cd\u65b9\u5f0f\u53ef\u4ee5\u8ba9DOM\u8131\u79bb\u6587\u6863\u6d41\uff1a<\/p>\n<ul>\n<li>\u9690\u85cf\u5143\u7d20\uff0c\u5e94\u7528\u4fee\u6539\uff0c\u91cd\u65b0\u663e\u793a<\/li>\n<li>\u4f7f\u7528\u6587\u6863\u7247\u6bb5(document fragment)\u5728\u5f53\u524dDOM\u4e4b\u5916\u6784\u5efa\u4e00\u4e2a\u5b50\u6811\uff0c\u518d\u628a\u5b83\u62f7\u8d1d\u56de\u6587\u6863\u3002<\/li>\n<li>\u5c06\u539f\u59cb\u5143\u7d20\u62f7\u8d1d\u5230\u4e00\u4e2a\u8131\u79bb\u6587\u6863\u7684\u8282\u70b9\u4e2d\uff0c\u4fee\u6539\u8282\u70b9\u540e\uff0c\u518d\u66ff\u6362\u539f\u59cb\u7684\u5143\u7d20\u3002<\/li>\n<\/ul>\n<p>\u8003\u8651\u6211\u4eec\u8981\u6267\u884c\u4e00\u6bb5\u6279\u91cf\u63d2\u5165\u8282\u70b9\u7684\u4ee3\u7801\uff1a<\/p>\n<pre class=\"javascript hljs\"><code class=\"javascript\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">appendDataToElement<\/span>(<span class=\"hljs-params\">appendToElement, data<\/span>) <\/span>{\r\n    <span class=\"hljs-keyword\">let<\/span> li;\r\n    <span class=\"hljs-keyword\">for<\/span> (<span class=\"hljs-keyword\">let<\/span> i = <span class=\"hljs-number\">0<\/span>; i &lt; data.length; i++) {\r\n        li = <span class=\"hljs-built_in\">document<\/span>.createElement(<span class=\"hljs-string\">'li'<\/span>);\r\n        li.textContent = <span class=\"hljs-string\">'text'<\/span>;\r\n        appendToElement.appendChild(li);\r\n    }\r\n}\r\n\r\n<span class=\"hljs-keyword\">const<\/span> ul = <span class=\"hljs-built_in\">document<\/span>.getElementById(<span class=\"hljs-string\">'list'<\/span>);\r\nappendDataToElement(ul, data);<\/code><\/pre>\n<p>\u5982\u679c\u6211\u4eec\u76f4\u63a5\u8fd9\u6837\u6267\u884c\u7684\u8bdd\uff0c\u7531\u4e8e\u6bcf\u6b21\u5faa\u73af\u90fd\u4f1a\u63d2\u5165\u4e00\u4e2a\u65b0\u7684\u8282\u70b9\uff0c\u4f1a\u5bfc\u81f4\u6d4f\u89c8\u5668\u56de\u6d41\u4e00\u6b21\u3002<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e09\u79cd\u65b9\u5f0f\u8fdb\u884c\u4f18\u5316:<\/p>\n<p><strong>\u9690\u85cf\u5143\u7d20\uff0c\u5e94\u7528\u4fee\u6539\uff0c\u91cd\u65b0\u663e\u793a<\/strong><\/p>\n<p>\u8fd9\u4e2a\u4f1a\u5728\u5c55\u793a\u548c\u9690\u85cf\u8282\u70b9\u7684\u65f6\u5019\uff0c\u4ea7\u751f\u4e24\u6b21\u91cd\u7ed8<\/p>\n<pre class=\"javascript hljs\"><code class=\"javascript\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">appendDataToElement<\/span>(<span class=\"hljs-params\">appendToElement, data<\/span>) <\/span>{\r\n    <span class=\"hljs-keyword\">let<\/span> li;\r\n    <span class=\"hljs-keyword\">for<\/span> (<span class=\"hljs-keyword\">let<\/span> i = <span class=\"hljs-number\">0<\/span>; i &lt; data.length; i++) {\r\n        li = <span class=\"hljs-built_in\">document<\/span>.createElement(<span class=\"hljs-string\">'li'<\/span>);\r\n        li.textContent = <span class=\"hljs-string\">'text'<\/span>;\r\n        appendToElement.appendChild(li);\r\n    }\r\n}\r\n<span class=\"hljs-keyword\">const<\/span> ul = <span class=\"hljs-built_in\">document<\/span>.getElementById(<span class=\"hljs-string\">'list'<\/span>);\r\nul.style.display = <span class=\"hljs-string\">'none'<\/span>;\r\nappendDataToElement(ul, data);\r\nul.style.display = <span class=\"hljs-string\">'block'<\/span>;<\/code><\/pre>\n<p><strong>\u4f7f\u7528\u6587\u6863\u7247\u6bb5(document fragment)\u5728\u5f53\u524dDOM\u4e4b\u5916\u6784\u5efa\u4e00\u4e2a\u5b50\u6811\uff0c\u518d\u628a\u5b83\u62f7\u8d1d\u56de\u6587\u6863<\/strong><\/p>\n<pre class=\"javascript hljs\"><code class=\"javascript\"><span class=\"hljs-keyword\">const<\/span> ul = <span class=\"hljs-built_in\">document<\/span>.getElementById(<span class=\"hljs-string\">'list'<\/span>);\r\n<span class=\"hljs-keyword\">const<\/span> fragment = <span class=\"hljs-built_in\">document<\/span>.createDocumentFragment();\r\nappendDataToElement(fragment, data);\r\nul.appendChild(fragment);<\/code><\/pre>\n<p><strong>\u5c06\u539f\u59cb\u5143\u7d20\u62f7\u8d1d\u5230\u4e00\u4e2a\u8131\u79bb\u6587\u6863\u7684\u8282\u70b9\u4e2d\uff0c\u4fee\u6539\u8282\u70b9\u540e\uff0c\u518d\u66ff\u6362\u539f\u59cb\u7684\u5143\u7d20\u3002<\/strong><\/p>\n<pre class=\"javascript hljs\"><code class=\"javascript\"><span class=\"hljs-keyword\">const<\/span> ul = <span class=\"hljs-built_in\">document<\/span>.getElementById(<span class=\"hljs-string\">'list'<\/span>);\r\n<span class=\"hljs-keyword\">const<\/span> clone = ul.cloneNode(<span class=\"hljs-literal\">true<\/span>);\r\nappendDataToElement(clone, data);\r\nul.parentNode.replaceChild(clone, ul);<\/code><\/pre>\n<p>\u5bf9\u4e8e\u4e0a\u8ff0\u90a3\u79cd\u60c5\u51b5\uff0c\u6211\u5199\u4e86\u4e00\u4e2a<a href=\"https:\/\/chenjigeng.github.io\/example\/share\/%E9%81%BF%E5%85%8D%E5%9B%9E%E6%B5%81%E9%87%8D%E7%BB%98\/%E6%89%B9%E9%87%8F%E4%BF%AE%E6%94%B9DOM.html\" target=\"_blank\" rel=\"nofollow noreferrer\">demo<\/a>\u6765\u6d4b\u8bd5\u4fee\u6539\u524d\u548c\u4fee\u6539\u540e\u7684\u6027\u80fd\u3002\u7136\u800c\u5b9e\u9a8c\u7ed3\u679c\u4e0d\u662f\u5f88\u7406\u60f3\u3002<\/p>\n<p><strong>\u539f\u56e0\uff1a\u539f\u56e0\u5176\u5b9e\u4e0a\u9762\u4e5f\u8bf4\u8fc7\u4e86\uff0c\u6d4f\u89c8\u5668\u4f1a\u4f7f\u7528\u961f\u5217\u6765\u50a8\u5b58\u591a\u6b21\u4fee\u6539\uff0c\u8fdb\u884c\u4f18\u5316\uff0c\u6240\u4ee5\u5bf9\u8fd9\u4e2a\u4f18\u5316\u65b9\u6848\uff0c\u6211\u4eec\u5176\u5b9e\u4e0d\u7528\u4f18\u5148\u8003\u8651\u3002<\/strong><\/p>\n<h3 id=\"item-4-6\">\u907f\u514d\u89e6\u53d1\u540c\u6b65\u5e03\u5c40\u4e8b\u4ef6<\/h3>\n<p>\u4e0a\u6587\u6211\u4eec\u8bf4\u8fc7\uff0c\u5f53\u6211\u4eec\u8bbf\u95ee\u5143\u7d20\u7684\u4e00\u4e9b\u5c5e\u6027\u7684\u65f6\u5019\uff0c\u4f1a\u5bfc\u81f4\u6d4f\u89c8\u5668\u5f3a\u5236\u6e05\u7a7a\u961f\u5217\uff0c\u8fdb\u884c\u5f3a\u5236\u540c\u6b65\u5e03\u5c40\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u6bd4\u5982\u8bf4\u6211\u4eec\u60f3\u5c06\u4e00\u4e2ap\u6807\u7b7e\u6570\u7ec4\u7684\u5bbd\u5ea6\u8d4b\u503c\u4e3a\u4e00\u4e2a\u5143\u7d20\u7684\u5bbd\u5ea6\uff0c\u6211\u4eec\u53ef\u80fd\u5199\u51fa\u8fd9\u6837\u7684\u4ee3\u7801\uff1a<\/p>\n<pre class=\"javascript hljs\"><code class=\"javascript\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">initP<\/span>() <\/span>{\r\n    <span class=\"hljs-keyword\">for<\/span> (<span class=\"hljs-keyword\">let<\/span> i = <span class=\"hljs-number\">0<\/span>; i &lt; paragraphs.length; i++) {\r\n        paragraphs[i].style.width = box.offsetWidth + <span class=\"hljs-string\">'px'<\/span>;\r\n    }\r\n}<\/code><\/pre>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u770b\u4e0a\u53bb\u662f\u6ca1\u6709\u4ec0\u4e48\u95ee\u9898\uff0c\u53ef\u662f\u5176\u5b9e\u4f1a\u9020\u6210\u5f88\u5927\u7684\u6027\u80fd\u95ee\u9898\u3002\u5728\u6bcf\u6b21\u5faa\u73af\u7684\u65f6\u5019\uff0c\u90fd\u8bfb\u53d6\u4e86box\u7684\u4e00\u4e2aoffsetWidth\u5c5e\u6027\u503c\uff0c\u7136\u540e\u5229\u7528\u5b83\u6765\u66f4\u65b0p\u6807\u7b7e\u7684width\u5c5e\u6027\u3002\u8fd9\u5c31\u5bfc\u81f4\u4e86\u6bcf\u4e00\u6b21\u5faa\u73af\u7684\u65f6\u5019\uff0c\u6d4f\u89c8\u5668\u90fd\u5fc5\u987b\u5148\u4f7f\u4e0a\u4e00\u6b21\u5faa\u73af\u4e2d\u7684\u6837\u5f0f\u66f4\u65b0\u64cd\u4f5c\u751f\u6548\uff0c\u624d\u80fd\u54cd\u5e94\u672c\u6b21\u5faa\u73af\u7684\u6837\u5f0f\u8bfb\u53d6\u64cd\u4f5c\u3002\u6bcf\u4e00\u6b21\u5faa\u73af\u90fd\u4f1a\u5f3a\u5236\u6d4f\u89c8\u5668\u5237\u65b0\u961f\u5217\u3002\u6211\u4eec\u53ef\u4ee5\u4f18\u5316\u4e3a:<\/p>\n<pre class=\"javascript hljs\"><code class=\"javascript\"><span class=\"hljs-keyword\">const<\/span> width = box.offsetWidth;\r\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">initP<\/span>() <\/span>{\r\n    <span class=\"hljs-keyword\">for<\/span> (<span class=\"hljs-keyword\">let<\/span> i = <span class=\"hljs-number\">0<\/span>; i &lt; paragraphs.length; i++) {\r\n        paragraphs[i].style.width = width + <span class=\"hljs-string\">'px'<\/span>;\r\n    }\r\n}<\/code><\/pre>\n<p>\u540c\u6837\uff0c\u6211\u4e5f\u5199\u4e86\u4e2a<a href=\"https:\/\/chenjigeng.github.io\/example\/share\/%E9%81%BF%E5%85%8D%E5%9B%9E%E6%B5%81%E9%87%8D%E7%BB%98\/%E9%81%BF%E5%85%8D%E5%BF%AB%E9%80%9F%E8%BF%9E%E7%BB%AD%E7%9A%84%E5%B8%83%E5%B1%80.html\" target=\"_blank\" rel=\"nofollow noreferrer\">demo<\/a>\u6765\u6bd4\u8f83\u4e24\u8005\u7684\u6027\u80fd\u5dee\u5f02\u3002\u4f60\u53ef\u4ee5\u81ea\u5df1\u70b9\u5f00\u8fd9\u4e2ademo\u4f53\u9a8c\u4e0b\u3002\u8fd9\u4e2a\u5bf9\u6bd4\u5dee\u8ddd\u5c31\u6bd4\u8f83\u660e\u663e\u3002<\/p>\n<h3 id=\"item-4-7\">\u5bf9\u4e8e\u590d\u6742\u52a8\u753b\u6548\u679c,\u4f7f\u7528\u7edd\u5bf9\u5b9a\u4f4d\u8ba9\u5176\u8131\u79bb\u6587\u6863\u6d41<\/h3>\n<p>\u5bf9\u4e8e\u590d\u6742\u52a8\u753b\u6548\u679c\uff0c\u7531\u4e8e\u4f1a\u7ecf\u5e38\u7684\u5f15\u8d77\u56de\u6d41\u91cd\u7ed8\uff0c\u56e0\u6b64\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u7edd\u5bf9\u5b9a\u4f4d\uff0c\u8ba9\u5b83\u8131\u79bb\u6587\u6863\u6d41\u3002\u5426\u5219\u4f1a\u5f15\u8d77\u7236\u5143\u7d20\u4ee5\u53ca\u540e\u7eed\u5143\u7d20\u9891\u7e41\u7684\u56de\u6d41\u3002\u8fd9\u4e2a\u6211\u4eec\u5c31\u76f4\u63a5\u4e0a\u4e2a<a href=\"https:\/\/chenjigeng.github.io\/example\/share\/%E9%81%BF%E5%85%8D%E5%9B%9E%E6%B5%81%E9%87%8D%E7%BB%98\/%E5%B0%86%E5%A4%8D%E6%9D%82%E5%8A%A8%E7%94%BB%E6%B5%AE%E5%8A%A8%E5%8C%96.html\" target=\"_blank\" rel=\"nofollow noreferrer\">\u4f8b\u5b50<\/a>\u3002<\/p>\n<p>\u6253\u5f00\u8fd9\u4e2a\u4f8b\u5b50\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u6253\u5f00\u63a7\u5236\u53f0\uff0c\u63a7\u5236\u53f0\u4e0a\u4f1a\u8f93\u51fa\u5f53\u524d\u7684\u5e27\u6570(\u867d\u7136\u4e0d\u51c6)\u3002<\/p>\n<p><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/760752144-5c0f11b283530_articlex.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2642\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/760752144-5c0f11b283530_articlex.png\" alt=\"760752144-5c0f11b283530_articlex\" width=\"800\" height=\"231\" \/><\/a><\/p>\n<p>\u4ece\u4e0a\u56fe\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0c\u5e27\u6570\u4e00\u76f4\u90fd\u6ca1\u523060\u3002\u8fd9\u4e2a\u65f6\u5019\uff0c\u53ea\u8981\u6211\u4eec\u70b9\u51fb\u4e00\u4e0b\u90a3\u4e2a\u6309\u94ae\uff0c\u628a\u8fd9\u4e2a\u5143\u7d20\u8bbe\u7f6e\u4e3a\u7edd\u5bf9\u5b9a\u4f4d\uff0c\u5e27\u6570\u5c31\u53ef\u4ee5\u7a33\u5b9a60\u3002<\/p>\n<h3 id=\"item-4-8\">css3\u786c\u4ef6\u52a0\u901f\uff08GPU\u52a0\u901f\uff09<\/h3>\n<p>\u6bd4\u8d77\u8003\u8651\u5982\u4f55\u51cf\u5c11\u56de\u6d41\u91cd\u7ed8\uff0c\u6211\u4eec\u66f4\u671f\u671b\u7684\u662f\uff0c\u6839\u672c\u4e0d\u8981\u56de\u6d41\u91cd\u7ed8\u3002\u8fd9\u4e2a\u65f6\u5019\uff0ccss3\u786c\u4ef6\u52a0\u901f\u5c31\u95ea\u4eae\u767b\u573a\u5566\uff01\uff01<\/p>\n<p><strong>\u5212\u91cd\u70b9\uff1a\u4f7f\u7528css3\u786c\u4ef6\u52a0\u901f\uff0c\u53ef\u4ee5\u8ba9transform\u3001opacity\u3001filters\u8fd9\u4e9b\u52a8\u753b\u4e0d\u4f1a\u5f15\u8d77\u56de\u6d41\u91cd\u7ed8 \u3002\u4f46\u662f\u5bf9\u4e8e\u52a8\u753b\u7684\u5176\u5b83\u5c5e\u6027\uff0c\u6bd4\u5982background-color\u8fd9\u4e9b\uff0c\u8fd8\u662f\u4f1a\u5f15\u8d77\u56de\u6d41\u91cd\u7ed8\u7684\uff0c\u4e0d\u8fc7\u5b83\u8fd8\u662f\u53ef\u4ee5\u63d0\u5347\u8fd9\u4e9b\u52a8\u753b\u7684\u6027\u80fd\u3002<\/strong><\/p>\n<p>\u672c\u7bc7\u6587\u7ae0\u53ea\u8ba8\u8bba\u5982\u4f55\u4f7f\u7528\uff0c\u6682\u4e0d\u8003\u8651\u5176\u539f\u7406\uff0c\u4e4b\u540e\u6709\u7a7a\u4f1a\u53e6\u5916\u5f00\u7bc7\u6587\u7ae0\u8bf4\u660e\u3002<\/p>\n<h4>\u5982\u4f55\u4f7f\u7528<\/h4>\n<p>\u5e38\u89c1\u7684\u89e6\u53d1\u786c\u4ef6\u52a0\u901f\u7684css\u5c5e\u6027\uff1a<\/p>\n<ul>\n<li>transform<\/li>\n<li>opacity<\/li>\n<li>filters<\/li>\n<li>Will-change<\/li>\n<\/ul>\n<h4>\u6548\u679c<\/h4>\n<p>\u6211\u4eec\u53ef\u4ee5\u5148\u770b\u4e2a<a href=\"https:\/\/chenjigeng.github.io\/example\/share\/%E5%AF%B9%E6%AF%94gpu%E5%8A%A0%E9%80%9F\/gpu%E5%8A%A0%E9%80%9F-transform.html\" target=\"_blank\" rel=\"nofollow noreferrer\">\u4f8b\u5b50<\/a>\u3002\u6211\u901a\u8fc7\u4f7f\u7528chrome\u7684Performance\u6355\u83b7\u4e86\u4e00\u6bb5\u65f6\u95f4\u7684\u56de\u6d41\u91cd\u7ed8\u60c5\u51b5\uff0c\u5b9e\u9645\u7ed3\u679c\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/4015752135-5c0f11b277b7d_articlex.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2643\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/4015752135-5c0f11b277b7d_articlex.png\" alt=\"4015752135-5c0f11b277b7d_articlex\" width=\"339\" height=\"217\" \/><\/a><\/p>\n<p>\u4ece\u56fe\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\uff0c\u5728\u52a8\u753b\u8fdb\u884c\u7684\u65f6\u5019\uff0c\u6ca1\u6709\u53d1\u751f\u4efb\u4f55\u7684\u56de\u6d41\u91cd\u7ed8\u3002\u5982\u679c\u611f\u5174\u8da3\u4f60\u4e5f\u53ef\u4ee5\u81ea\u5df1\u505a\u4e0b\u5b9e\u9a8c\u3002<\/p>\n<h4>\u91cd\u70b9<\/h4>\n<ul>\n<li>\u4f7f\u7528css3\u786c\u4ef6\u52a0\u901f\uff0c\u53ef\u4ee5\u8ba9transform\u3001opacity\u3001filters\u8fd9\u4e9b\u52a8\u753b\u4e0d\u4f1a\u5f15\u8d77\u56de\u6d41\u91cd\u7ed8<\/li>\n<li>\u5bf9\u4e8e\u52a8\u753b\u7684\u5176\u5b83\u5c5e\u6027\uff0c\u6bd4\u5982background-color\u8fd9\u4e9b\uff0c\u8fd8\u662f\u4f1a\u5f15\u8d77\u56de\u6d41\u91cd\u7ed8\u7684\uff0c\u4e0d\u8fc7\u5b83\u8fd8\u662f\u53ef\u4ee5\u63d0\u5347\u8fd9\u4e9b\u52a8\u753b\u7684\u6027\u80fd\u3002<\/li>\n<\/ul>\n<h4>css3\u786c\u4ef6\u52a0\u901f\u7684\u5751<\/h4>\n<ul>\n<li>\u5982\u679c\u4f60\u4e3a\u592a\u591a\u5143\u7d20\u4f7f\u7528css3\u786c\u4ef6\u52a0\u901f\uff0c\u4f1a\u5bfc\u81f4\u5185\u5b58\u5360\u7528\u8f83\u5927\uff0c\u4f1a\u6709\u6027\u80fd\u95ee\u9898\u3002<\/li>\n<li>\u5728GPU\u6e32\u67d3\u5b57\u4f53\u4f1a\u5bfc\u81f4\u6297\u952f\u9f7f\u65e0\u6548\u3002\u8fd9\u662f\u56e0\u4e3aGPU\u548cCPU\u7684\u7b97\u6cd5\u4e0d\u540c\u3002\u56e0\u6b64\u5982\u679c\u4f60\u4e0d\u5728\u52a8\u753b\u7ed3\u675f\u7684\u65f6\u5019\u5173\u95ed\u786c\u4ef6\u52a0\u901f\uff0c\u4f1a\u4ea7\u751f\u5b57\u4f53\u6a21\u7cca\u3002<\/li>\n<\/ul>\n<h2 id=\"item-5\">\u603b\u7ed3<\/h2>\n<p>\u672c\u6587\u4e3b\u8981\u8bb2\u4e86\u6d4f\u89c8\u5668\u7684\u6e32\u67d3\u8fc7\u7a0b\u3001\u6d4f\u89c8\u5668\u7684\u4f18\u5316\u673a\u5236\u4ee5\u53ca\u5982\u4f55\u51cf\u5c11\u751a\u81f3\u907f\u514d\u56de\u6d41\u548c\u91cd\u7ed8\uff0c\u5e0c\u671b\u53ef\u4ee5\u5e2e\u52a9\u5927\u5bb6\u66f4\u597d\u7684\u7406\u89e3\u56de\u6d41\u91cd\u7ed8\u3002<\/p>\n<h2 id=\"item-6\">\u53c2\u8003\u6587\u732e<\/h2>\n<ul>\n<li><a href=\"https:\/\/developers.google.com\/web\/fundamentals\/performance\/critical-rendering-path\/render-tree-construction?hl=zh-cn\" target=\"_blank\" rel=\"nofollow noreferrer\">\u6e32\u67d3\u6811\u6784\u5efa\u3001\u5e03\u5c40\u53ca\u7ed8\u5236<\/a><\/li>\n<li>\u9ad8\u6027\u80fdJavascript<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u56de\u6d41\u548c\u91cd\u7ed8\u53ef\u4ee5\u8bf4\u662f\u6bcf\u4e00\u4e2aweb\u5f00\u53d1\u8005\u90fd\u7ecf\u5e38\u542c\u5230\u7684\u4e24\u4e2a\u8bcd\u8bed\uff0c\u6211\u4e5f\u4e0d\u4f8b\u5916\uff0c\u53ef\u662f\u6211\u4e4b\u524d\u4e00\u76f4\u4e0d\u662f\u5f88\u6e05\u695a\u8fd9\u4e24\u6b65\u5177\u4f53\u505a\u4e86\u4ec0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[105,127],"tags":[],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2636"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2636"}],"version-history":[{"count":1,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2636\/revisions"}],"predecessor-version":[{"id":2644,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2636\/revisions\/2644"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2636"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}