{"id":2612,"date":"2020-04-13T20:28:13","date_gmt":"2020-04-13T12:28:13","guid":{"rendered":"http:\/\/www.yuguoxy.com\/geekhome\/?p=2612"},"modified":"2020-04-15T08:31:11","modified_gmt":"2020-04-15T00:31:11","slug":"%e5%89%8d%e7%ab%af%e6%80%a7%e8%83%bd%e4%bc%98%e5%8c%96-24-%e6%9d%a1%e5%bb%ba%e8%ae%ae%ef%bc%882020%ef%bc%89","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=2612","title":{"rendered":"\u524d\u7aef\u6027\u80fd\u4f18\u5316 24 \u6761\u5efa\u8bae\uff082020\uff09"},"content":{"rendered":"<p>\u6027\u80fd\u4f18\u5316\u662f\u628a\u53cc\u5203\u5251\uff0c\u6709\u597d\u7684\u4e00\u9762\u4e5f\u6709\u574f\u7684\u4e00\u9762\u3002\u597d\u7684\u4e00\u9762\u5c31\u662f\u80fd\u63d0\u5347\u7f51\u7ad9\u6027\u80fd\uff0c\u574f\u7684\u4e00\u9762\u5c31\u662f\u914d\u7f6e\u9ebb\u70e6\uff0c\u6216\u8005\u8981\u9075\u5b88\u7684\u89c4\u5219\u592a\u591a\u3002\u5e76\u4e14\u67d0\u4e9b\u6027\u80fd\u4f18\u5316\u89c4\u5219\u5e76\u4e0d\u9002\u7528\u6240\u6709\u573a\u666f\uff0c\u9700\u8981\u8c28\u614e\u4f7f\u7528\uff0c\u8bf7\u8bfb\u8005\u5e26\u7740\u6279\u5224\u6027\u7684\u773c\u5149\u6765\u9605\u8bfb\u672c\u6587\u3002<br \/>\n\u672c\u6587\u76f8\u5173\u7684\u4f18\u5316\u5efa\u8bae\u7684\u5f15\u7528\u8d44\u6599\u51fa\u5904\u5747\u4f1a\u5728\u5efa\u8bae\u540e\u9762\u7ed9\u51fa\uff0c\u6216\u8005\u653e\u5728\u6587\u672b\uff08\u6709\u4e9b\u53c2\u8003\u8d44\u6599\u53ef\u80fd\u8981\u68af\u5b50\u624d\u80fd\u89c2\u770b\uff09\u3002<\/p>\n<h4>1. \u51cf\u5c11 HTTP \u8bf7\u6c42<\/h4>\n<p>\u4e00\u4e2a HTTP \u8bf7\u6c42\u8fc7\u7a0b\uff1a<br \/>\n<a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/20200413202413.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2614\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/20200413202413.png\" alt=\"20200413202413\" width=\"855\" height=\"487\" \/><\/a><br \/>\n\u4e00\u4e2a HTTP \u8bf7\u6c42\u9700\u8981\u7ecf\u5386\u4ee5\u4e0a\u8fc7\u7a0b\uff0c\u63a5\u4e0b\u6765\u770b\u4e00\u4e2a\u5177\u4f53\u7684\u4f8b\u5b50\uff1a<br \/>\n<a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/20200413202441.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2615\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/20200413202441.png\" alt=\"20200413202441\" width=\"558\" height=\"404\" srcset=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/20200413202441.png 558w, https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/20200413202441-140x100.png 140w\" sizes=\"(max-width: 558px) 100vw, 558px\" \/><\/a><br \/>\n\u8fd9\u662f\u4e00\u4e2a HTTP \u8bf7\u6c42\uff0c\u8bf7\u6c42\u7684\u6587\u4ef6\u5927\u5c0f\u4e3a 28.4KB\u3002<\/p>\n<p>\u540d\u8bcd\u89e3\u91ca\uff1a<\/p>\n<ul>\n<li>Queueing: \u5728\u8bf7\u6c42\u961f\u5217\u4e2d\u7684\u65f6\u95f4\u3002<\/li>\n<li>Stalled: \u4eceTCP \u8fde\u63a5\u5efa\u7acb\u5b8c\u6210\uff0c\u5230\u771f\u6b63\u53ef\u4ee5\u4f20\u8f93\u6570\u636e\u4e4b\u95f4\u7684\u65f6\u95f4\u5dee\uff0c\u6b64\u65f6\u95f4\u5305\u62ec\u4ee3\u7406\u534f\u5546\u65f6\u95f4\u3002<\/li>\n<li>Proxy negotiation: \u4e0e\u4ee3\u7406\u670d\u52a1\u5668\u8fde\u63a5\u8fdb\u884c\u534f\u5546\u6240\u82b1\u8d39\u7684\u65f6\u95f4\u3002<\/li>\n<li>DNS Lookup: \u6267\u884cDNS\u67e5\u627e\u6240\u82b1\u8d39\u7684\u65f6\u95f4\uff0c\u9875\u9762\u4e0a\u7684\u6bcf\u4e2a\u4e0d\u540c\u7684\u57df\u90fd\u9700\u8981\u8fdb\u884cDNS\u67e5\u627e\u3002<\/li>\n<li>Initial Connection \/ Connecting: \u5efa\u7acb\u8fde\u63a5\u6240\u82b1\u8d39\u7684\u65f6\u95f4\uff0c\u5305\u62ecTCP\u63e1\u624b\/\u91cd\u8bd5\u548c\u534f\u5546SSL\u3002<\/li>\n<li>SSL: \u5b8c\u6210SSL\u63e1\u624b\u6240\u82b1\u8d39\u7684\u65f6\u95f4\u3002<\/li>\n<li>Request sent: \u53d1\u51fa\u7f51\u7edc\u8bf7\u6c42\u6240\u82b1\u8d39\u7684\u65f6\u95f4\uff0c\u901a\u5e38\u4e3a\u4e00\u6beb\u79d2\u7684\u65f6\u95f4\u3002<\/li>\n<li>Waiting(TFFB): TFFB \u662f\u53d1\u51fa\u9875\u9762\u8bf7\u6c42\u5230\u63a5\u6536\u5230\u5e94\u7b54\u6570\u636e\u7b2c\u4e00\u4e2a\u5b57\u8282\u7684\u65f6\u95f4\u603b\u548c\uff0c\u5b83\u5305\u542b\u4e86 DNS \u89e3\u6790\u65f6\u95f4\u3001 TCP \u8fde\u63a5\u65f6\u95f4\u3001\u53d1\u9001 HTTP \u8bf7\u6c42\u65f6\u95f4\u548c\u83b7\u5f97\u54cd\u5e94\u6d88\u606f\u7b2c\u4e00\u4e2a\u5b57\u8282\u7684\u65f6\u95f4\u3002<\/li>\n<li>Content Download: \u63a5\u6536\u54cd\u5e94\u6570\u636e\u6240\u82b1\u8d39\u7684\u65f6\u95f4\u3002<\/li>\n<\/ul>\n<p>\u4ece\u8fd9\u4e2a\u4f8b\u5b50\u53ef\u4ee5\u770b\u51fa\uff0c\u771f\u6b63\u4e0b\u8f7d\u6570\u636e\u7684\u65f6\u95f4\u5360\u6bd4\u4e3a\u00a0<code>13.05 \/ 204.16 = 6.39%<\/code>\uff0c\u6587\u4ef6\u8d8a\u5c0f\uff0c\u8fd9\u4e2a\u6bd4\u4f8b\u8d8a\u5c0f\uff0c\u6587\u4ef6\u8d8a\u5927\uff0c\u6bd4\u4f8b\u5c31\u8d8a\u9ad8\u3002\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u8981\u5efa\u8bae\u5c06\u591a\u4e2a\u5c0f\u6587\u4ef6\u5408\u5e76\u4e3a\u4e00\u4e2a\u5927\u6587\u4ef6\uff0c\u4ece\u800c\u51cf\u5c11 HTTP \u8bf7\u6c42\u6b21\u6570\u7684\u539f\u56e0\u3002<\/p>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/developers.google.com\/web\/tools\/chrome-devtools\/network\/understanding-resource-timing\" target=\"_blank\" rel=\"nofollow noreferrer\">understanding-resource-timing<\/a><\/li>\n<\/ul>\n<h4>2. \u4f7f\u7528 HTTP2<\/h4>\n<blockquote><p>HTTP1.x \u5ba2\u6237\u7aef\u9700\u8981\u4f7f\u7528\u591a\u4e2a\u8fde\u63a5\u624d\u80fd\u5b9e\u73b0\u5e76\u53d1\u548c\u7f29\u77ed\u5ef6\u8fdf\uff1bHTTP1.x \u4e0d\u4f1a\u538b\u7f29\u8bf7\u6c42\u548c\u54cd\u5e94\u6807\u5934\uff0c\u4ece\u800c\u5bfc\u81f4\u4e0d\u5fc5\u8981\u7684\u7f51\u7edc\u6d41\u91cf\uff1bHTTP1.x \u4e0d\u652f\u6301\u6709\u6548\u7684\u8d44\u6e90\u4f18\u5148\u7ea7\uff0c\u81f4\u4f7f\u5e95\u5c42 TCP \u8fde\u63a5\u7684\u5229\u7528\u7387\u4f4e\u4e0b\u7b49\u7b49\u3002<\/p><\/blockquote>\n<p>HTTP2 \u662f\u5bf9\u4e4b\u524d HTTP \u6807\u51c6\u7684\u6269\u5c55\uff0c\u5b83\u901a\u8fc7\u652f\u6301\u6807\u5934\u5b57\u6bb5\u538b\u7f29\u548c\u5728\u540c\u4e00\u8fde\u63a5\u4e0a\u8fdb\u884c\u591a\u4e2a\u5e76\u53d1\u4ea4\u6362\uff0c\u8ba9\u5e94\u7528\u66f4\u6709\u6548\u5730\u5229\u7528\u7f51\u7edc\u8d44\u6e90\uff0c\u51cf\u5c11\u611f\u77e5\u7684\u5ef6\u8fdf\u65f6\u95f4\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u5b83\u53ef\u4ee5\u5bf9\u540c\u4e00\u8fde\u63a5\u4e0a\u7684\u8bf7\u6c42\u548c\u54cd\u5e94\u6d88\u606f\u8fdb\u884c\u4ea4\u9519\u53d1\u9001\u5e76\u4e3a HTTP \u6807\u5934\u5b57\u6bb5\u4f7f\u7528\u6709\u6548\u7f16\u7801\u3002<\/p>\n<p>HTTP2 \u8fd8\u5141\u8bb8\u4e3a\u8bf7\u6c42\u8bbe\u7f6e\u4f18\u5148\u7ea7\uff0c\u8ba9\u66f4\u91cd\u8981\u7684\u8bf7\u6c42\u66f4\u5feb\u901f\u5730\u5b8c\u6210\uff0c\u4ece\u800c\u8fdb\u4e00\u6b65\u63d0\u5347\u6027\u80fd\u3002<\/p>\n<p>HTTP2 \u652f\u6301\u4e86\u591a\u8def\u590d\u7528\uff0cHTTP \u8fde\u63a5\u53d8\u5f97\u5341\u5206\u5ec9\u4ef7\uff0c\u4e4b\u524d\u4e3a\u4e86\u8282\u7701\u8fde\u63a5\u6570\u6240\u91c7\u7528\u7684\u7c7b\u4f3c\u4e8e\u300c\u8d44\u6e90\u5408\u5e76\u3001\u8d44\u6e90\u5185\u8054\u300d\u7b49\u4f18\u5316\u624b\u6bb5\u4e0d\u518d\u9700\u8981\u4e86\u3002\u591a\u8def\u590d\u7528\u53ef\u4ee5\u5728\u4e00\u4e2a TCP \u8fde\u63a5\u4e0a\u5efa\u7acb\u5927\u91cf HTTP \u8fde\u63a5\uff0c\u4e5f\u5c31\u4e0d\u5b58\u5728 HTTP \u8fde\u63a5\u6570\u9650\u5236\u4e86\uff0cHTTP1.x \u4e2d\u5e38\u89c1\u7684\u300c\u9759\u6001\u57df\u540d\u300d\u4f18\u5316\u7b56\u7565\u4e0d\u4f46\u7528\u4e0d\u4e0a\u4e86\uff0c\u8fd8\u4f1a\u5e26\u6765\u8d1f\u9762\u5f71\u54cd\uff0c\u9700\u8981\u53bb\u6389\u3002\u53e6\u5916\uff0cHTTP2 \u7684\u5934\u90e8\u538b\u7f29\u529f\u80fd\u4e5f\u80fd\u5927\u5e45\u51cf\u5c11 HTTP \u534f\u8bae\u5934\u90e8\u5e26\u6765\u7684\u5f00\u9500\u3002\u4f46\u662f\uff0c\u8981\u7b49HTTP1.x \u5b8c\u5168\u9000\u51fa\u821e\u53f0\u8fd8\u9700\u8981\u4e00\u6bb5\u65f6\u95f4\u3002<\/p>\n<p>\u73b0\u5728\u6709\u5f88\u591a\u7f51\u7ad9\u5df2\u7ecf\u5f00\u59cb\u4f7f\u7528 HTTP2 \u4e86\uff0c\u4f8b\u5982\u77e5\u4e4e\uff1a<br \/>\n<a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/QQ\u255c\u256a\u2550\u255d20200413202503.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2616\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/QQ\u255c\u256a\u2550\u255d20200413202503.png\" alt=\"QQ\u255c\u256a\u2550\u255d20200413202503\" width=\"511\" height=\"250\" \/><\/a><br \/>\n\u5176\u4e2d h2 \u662f\u6307 HTTP2 \u534f\u8bae\uff0chttp\/1.1 \u5219\u662f\u6307 HTTP1.1 \u534f\u8bae\u3002<\/p>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/developers.google.com\/web\/fundamentals\/performance\/http2\/?hl=zh-cn\" target=\"_blank\" rel=\"nofollow noreferrer\">HTTP2 \u7b80\u4ecb<\/a><\/li>\n<li><a href=\"https:\/\/imququ.com\/post\/http2-and-wpo-3.html#toc-3\" target=\"_blank\" rel=\"nofollow noreferrer\">HTTP2 \u4e0e WEB \u6027\u80fd\u4f18\u5316\uff08\u4e09\uff09<\/a><\/li>\n<li><a href=\"https:\/\/juejin.im\/post\/5b0e9ff4518825153515aade\" target=\"_blank\" rel=\"nofollow noreferrer\">\u57fa\u4e8eNode.js\u7684HTTP\/2 Server\u5b9e\u8df5<\/a><\/li>\n<\/ul>\n<h4>3. \u4f7f\u7528\u670d\u52a1\u7aef\u6e32\u67d3<\/h4>\n<p>\u5ba2\u6237\u7aef\u6e32\u67d3: \u83b7\u53d6 HTML \u6587\u4ef6\uff0c\u6839\u636e\u9700\u8981\u4e0b\u8f7d JavaScript \u6587\u4ef6\uff0c\u8fd0\u884c\u6587\u4ef6\uff0c\u751f\u6210 DOM\uff0c\u518d\u6e32\u67d3\u3002<br \/>\n\u670d\u52a1\u7aef\u6e32\u67d3\uff1a\u670d\u52a1\u7aef\u8fd4\u56de HTML \u6587\u4ef6\uff0c\u5ba2\u6237\u7aef\u53ea\u9700\u89e3\u6790 HTML\u3002<\/p>\n<ul>\n<li>\u4f18\u70b9\uff1a\u9996\u5c4f\u6e32\u67d3\u5feb\uff0cSEO \u597d\u3002<\/li>\n<li>\u7f3a\u70b9\uff1a\u914d\u7f6e\u9ebb\u70e6\u3002<\/li>\n<\/ul>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/ssr.vuejs.org\/zh\/\" target=\"_blank\" rel=\"nofollow noreferrer\">Vue.js \u670d\u52a1\u5668\u7aef\u6e32\u67d3\u6307\u5357<\/a><\/li>\n<\/ul>\n<h4>4. \u9759\u6001\u8d44\u6e90\u4f7f\u7528 CDN<\/h4>\n<p>\u5185\u5bb9\u5206\u53d1\u7f51\u7edc\uff08CDN\uff09\u662f\u4e00\u7ec4\u5206\u5e03\u5728\u591a\u4e2a\u4e0d\u540c\u5730\u7406\u4f4d\u7f6e\u7684 Web \u670d\u52a1\u5668\u3002\u6211\u4eec\u90fd\u77e5\u9053\uff0c\u5f53\u670d\u52a1\u5668\u79bb\u7528\u6237\u8d8a\u8fdc\u65f6\uff0c\u5ef6\u8fdf\u8d8a\u9ad8\u3002CDN \u5c31\u662f\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\uff0c\u5728\u591a\u4e2a\u4f4d\u7f6e\u90e8\u7f72\u670d\u52a1\u5668\uff0c\u8ba9\u7528\u6237\u79bb\u670d\u52a1\u5668\u66f4\u8fd1\uff0c\u4ece\u800c\u7f29\u77ed\u8bf7\u6c42\u65f6\u95f4\u3002<\/p>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/www.zhihu.com\/question\/36514327\/answer\/193768864\" target=\"_blank\" rel=\"nofollow noreferrer\">CDN\u662f\u4ec0\u4e48\uff1f\u4f7f\u7528CDN\u6709\u4ec0\u4e48\u4f18\u52bf\uff1f<\/a><\/li>\n<\/ul>\n<h4>5. \u5c06 CSS \u653e\u5728\u6587\u4ef6\u5934\u90e8\uff0cJavaScript \u6587\u4ef6\u653e\u5728\u5e95\u90e8<\/h4>\n<p>\u6240\u6709\u653e\u5728 head \u6807\u7b7e\u91cc\u7684 CSS \u548c JS \u6587\u4ef6\u90fd\u4f1a\u5835\u585e\u6e32\u67d3\u3002\u5982\u679c\u8fd9\u4e9b CSS \u548c JS \u9700\u8981\u52a0\u8f7d\u548c\u89e3\u6790\u5f88\u4e45\u7684\u8bdd\uff0c\u90a3\u4e48\u9875\u9762\u5c31\u7a7a\u767d\u4e86\u3002\u6240\u4ee5 JS \u6587\u4ef6\u8981\u653e\u5728\u5e95\u90e8\uff0c\u7b49 HTML \u89e3\u6790\u5b8c\u4e86\u518d\u52a0\u8f7d JS \u6587\u4ef6\u3002<\/p>\n<p>\u90a3\u4e3a\u4ec0\u4e48 CSS \u6587\u4ef6\u8fd8\u8981\u653e\u5728\u5934\u90e8\u5462\uff1f<\/p>\n<p>\u56e0\u4e3a\u5148\u52a0\u8f7d HTML \u518d\u52a0\u8f7d CSS\uff0c\u4f1a\u8ba9\u7528\u6237\u7b2c\u4e00\u65f6\u95f4\u770b\u5230\u7684\u9875\u9762\u662f\u6ca1\u6709\u6837\u5f0f\u7684\u3001\u201c\u4e11\u964b\u201d\u7684\uff0c\u4e3a\u4e86\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u53d1\u751f\uff0c\u5c31\u8981\u5c06 CSS \u6587\u4ef6\u653e\u5728\u5934\u90e8\u4e86\u3002<\/p>\n<p>\u53e6\u5916\uff0cJS \u6587\u4ef6\u4e5f\u4e0d\u662f\u4e0d\u53ef\u4ee5\u653e\u5728\u5934\u90e8\uff0c\u53ea\u8981\u7ed9 script \u6807\u7b7e\u52a0\u4e0a defer \u5c5e\u6027\u5c31\u53ef\u4ee5\u4e86\uff0c\u5f02\u6b65\u4e0b\u8f7d\uff0c\u5ef6\u8fdf\u6267\u884c\u3002<\/p>\n<h4>6. \u4f7f\u7528\u5b57\u4f53\u56fe\u6807 iconfont \u4ee3\u66ff\u56fe\u7247\u56fe\u6807<\/h4>\n<p>\u5b57\u4f53\u56fe\u6807\u5c31\u662f\u5c06\u56fe\u6807\u5236\u4f5c\u6210\u4e00\u4e2a\u5b57\u4f53\uff0c\u4f7f\u7528\u65f6\u5c31\u8ddf\u5b57\u4f53\u4e00\u6837\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u5c5e\u6027\uff0c\u4f8b\u5982 font-size\u3001color \u7b49\u7b49\uff0c\u975e\u5e38\u65b9\u4fbf\u3002\u5e76\u4e14\u5b57\u4f53\u56fe\u6807\u662f\u77e2\u91cf\u56fe\uff0c\u4e0d\u4f1a\u5931\u771f\u3002\u8fd8\u6709\u4e00\u4e2a\u4f18\u70b9\u662f\u751f\u6210\u7684\u6587\u4ef6\u7279\u522b\u5c0f\u3002<\/p>\n<ul>\n<li><a href=\"https:\/\/www.iconfont.cn\/\" target=\"_blank\" rel=\"nofollow noreferrer\">Iconfont-\u963f\u91cc\u5df4\u5df4\u77e2\u91cf\u56fe\u6807\u5e93<\/a><\/li>\n<\/ul>\n<h4>7. \u5584\u7528\u7f13\u5b58\uff0c\u4e0d\u91cd\u590d\u52a0\u8f7d\u76f8\u540c\u7684\u8d44\u6e90<\/h4>\n<p>\u4e3a\u4e86\u907f\u514d\u7528\u6237\u6bcf\u6b21\u8bbf\u95ee\u7f51\u7ad9\u90fd\u5f97\u8bf7\u6c42\u6587\u4ef6\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u6dfb\u52a0 Expires \u5934\u6765\u63a7\u5236\u8fd9\u4e00\u884c\u4e3a\u3002Expires \u8bbe\u7f6e\u4e86\u4e00\u4e2a\u65f6\u95f4\uff0c\u53ea\u8981\u5728\u8fd9\u4e2a\u65f6\u95f4\u4e4b\u524d\uff0c\u6d4f\u89c8\u5668\u90fd\u4e0d\u4f1a\u8bf7\u6c42\u6587\u4ef6\uff0c\u800c\u662f\u76f4\u63a5\u4f7f\u7528\u7f13\u5b58\u3002<\/p>\n<p>\u4e0d\u8fc7\u8fd9\u6837\u4f1a\u4ea7\u751f\u4e00\u4e2a\u95ee\u9898\uff0c\u5f53\u6587\u4ef6\u66f4\u65b0\u4e86\u600e\u4e48\u529e\uff1f\u600e\u4e48\u901a\u77e5\u6d4f\u89c8\u5668\u91cd\u65b0\u8bf7\u6c42\u6587\u4ef6\uff1f<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u66f4\u65b0\u9875\u9762\u4e2d\u5f15\u7528\u7684 CSS \u94fe\u63a5\u5730\u5740\uff0c\u8ba9\u6d4f\u89c8\u5668\u4e3b\u52a8\u653e\u5f03\u7f13\u5b58\uff0c\u52a0\u8f7d\u65b0\u8d44\u6e90\u3002<\/p>\n<p>\u5177\u4f53\u505a\u6cd5\u662f\u628a CSS \u5730\u5740\u7684\u4fee\u6539\u4e0e\u6587\u4ef6\u5185\u5bb9\u5173\u8054\u8d77\u6765\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u53ea\u6709\u6587\u4ef6\u5185\u5bb9\u53d8\u5316\uff0c\u624d\u4f1a\u5bfc\u81f4\u76f8\u5e94 CSS \u5730\u5740\u7684\u53d8\u66f4\uff0c\u4ece\u800c\u5b9e\u73b0\u6587\u4ef6\u7ea7\u522b\u7684\u7cbe\u786e\u7f13\u5b58\u63a7\u5236\u3002\u4ec0\u4e48\u4e1c\u897f\u4e0e\u6587\u4ef6\u5185\u5bb9\u76f8\u5173\u5462\uff1f\u6211\u4eec\u4f1a\u5f88\u81ea\u7136\u7684\u8054\u60f3\u5230\u5229\u7528<a href=\"https:\/\/baike.baidu.com\/item\/%E6%B6%88%E6%81%AF%E6%91%98%E8%A6%81%E7%AE%97%E6%B3%95\/3286770?fromtitle=%E6%91%98%E8%A6%81%E7%AE%97%E6%B3%95&amp;fromid=12011257\" target=\"_blank\" rel=\"nofollow noreferrer\">\u6570\u636e\u6458\u8981\u8981\u7b97\u6cd5<\/a>\u5bf9\u6587\u4ef6\u6c42\u6458\u8981\u4fe1\u606f\uff0c\u6458\u8981\u4fe1\u606f\u4e0e\u6587\u4ef6\u5185\u5bb9\u4e00\u4e00\u5bf9\u5e94\uff0c\u5c31\u6709\u4e86\u4e00\u79cd\u53ef\u4ee5\u7cbe\u786e\u5230\u5355\u4e2a\u6587\u4ef6\u7c92\u5ea6\u7684\u7f13\u5b58\u63a7\u5236\u4f9d\u636e\u4e86\u3002<\/p>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/www.zhihu.com\/question\/20790576\/answer\/32602154\" target=\"_blank\" rel=\"nofollow noreferrer\">\u5f20\u4e91\u9f99&#8211;\u5927\u516c\u53f8\u91cc\u600e\u6837\u5f00\u53d1\u548c\u90e8\u7f72\u524d\u7aef\u4ee3\u7801\uff1f<\/a><\/li>\n<\/ul>\n<h4>8. \u538b\u7f29\u6587\u4ef6<\/h4>\n<p>\u538b\u7f29\u6587\u4ef6\u53ef\u4ee5\u51cf\u5c11\u6587\u4ef6\u4e0b\u8f7d\u65f6\u95f4\uff0c\u8ba9\u7528\u6237\u4f53\u9a8c\u6027\u66f4\u597d\u3002<\/p>\n<p>\u5f97\u76ca\u4e8e webpack \u548c node \u7684\u53d1\u5c55\uff0c\u73b0\u5728\u538b\u7f29\u6587\u4ef6\u5df2\u7ecf\u975e\u5e38\u65b9\u4fbf\u4e86\u3002<\/p>\n<p>\u5728 webpack \u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u63d2\u4ef6\u8fdb\u884c\u538b\u7f29\uff1a<\/p>\n<ul>\n<li>JavaScript\uff1aUglifyPlugin<\/li>\n<li>CSS \uff1aMiniCssExtractPlugin<\/li>\n<li>HTML\uff1aHtmlWebpackPlugin<\/li>\n<\/ul>\n<p>\u5176\u5b9e\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u505a\u5f97\u66f4\u597d\u3002\u90a3\u5c31\u662f\u4f7f\u7528 gzip \u538b\u7f29\u3002\u53ef\u4ee5\u901a\u8fc7\u5411 HTTP \u8bf7\u6c42\u5934\u4e2d\u7684 Accept-Encoding \u5934\u6dfb\u52a0 gzip \u6807\u8bc6\u6765\u5f00\u542f\u8fd9\u4e00\u529f\u80fd\u3002\u5f53\u7136\uff0c\u670d\u52a1\u5668\u4e5f\u5f97\u652f\u6301\u8fd9\u4e00\u529f\u80fd\u3002<\/p>\n<p>gzip \u662f\u76ee\u524d\u6700\u6d41\u884c\u548c\u6700\u6709\u6548\u7684\u538b\u7f29\u65b9\u6cd5\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u6211\u7528 Vue \u5f00\u53d1\u7684\u9879\u76ee\u6784\u5efa\u540e\u751f\u6210\u7684 app.js \u6587\u4ef6\u5927\u5c0f\u4e3a 1.4MB\uff0c\u4f7f\u7528 gzip \u538b\u7f29\u540e\u53ea\u6709 573KB\uff0c\u4f53\u79ef\u51cf\u5c11\u4e86\u5c06\u8fd1 60%\u3002<\/p>\n<p>\u9644\u4e0a webpack \u548c node \u914d\u7f6e gzip \u7684\u4f7f\u7528\u65b9\u6cd5\u3002<\/p>\n<p>\u4e0b\u8f7d\u63d2\u4ef6<\/p>\n<pre class=\"hljs sql\"><code>npm <span class=\"hljs-keyword\">install<\/span> compression-webpack-<span class=\"hljs-keyword\">plugin<\/span> <span class=\"hljs-comment\">--save-dev<\/span>\r\nnpm <span class=\"hljs-keyword\">install<\/span> compression<\/code><\/pre>\n<p>webpack \u914d\u7f6e<\/p>\n<pre class=\"hljs javascript\"><code><span class=\"hljs-keyword\">const<\/span> CompressionPlugin = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">'compression-webpack-plugin'<\/span>);\r\n\r\n<span class=\"hljs-built_in\">module<\/span>.exports = {\r\n  <span class=\"hljs-attr\">plugins<\/span>: [<span class=\"hljs-keyword\">new<\/span> CompressionPlugin()],\r\n}<\/code><\/pre>\n<p>node \u914d\u7f6e<\/p>\n<pre class=\"hljs php\"><code><span class=\"hljs-keyword\">const<\/span> compression = <span class=\"hljs-keyword\">require<\/span>(<span class=\"hljs-string\">'compression'<\/span>)\r\n<span class=\"hljs-comment\">\/\/ \u5728\u5176\u4ed6\u4e2d\u95f4\u4ef6\u524d\u4f7f\u7528<\/span>\r\napp.<span class=\"hljs-keyword\">use<\/span>(<span class=\"hljs-title\">compression<\/span>())<\/code><\/pre>\n<h4>9. \u56fe\u7247\u4f18\u5316<\/h4>\n<p><strong>(1). \u56fe\u7247\u5ef6\u8fdf\u52a0\u8f7d<\/strong><br \/>\n\u5728\u9875\u9762\u4e2d\uff0c\u5148\u4e0d\u7ed9\u56fe\u7247\u8bbe\u7f6e\u8def\u5f84\uff0c\u53ea\u6709\u5f53\u56fe\u7247\u51fa\u73b0\u5728\u6d4f\u89c8\u5668\u7684\u53ef\u89c6\u533a\u57df\u65f6\uff0c\u624d\u53bb\u52a0\u8f7d\u771f\u6b63\u7684\u56fe\u7247\uff0c\u8fd9\u5c31\u662f\u5ef6\u8fdf\u52a0\u8f7d\u3002\u5bf9\u4e8e\u56fe\u7247\u5f88\u591a\u7684\u7f51\u7ad9\u6765\u8bf4\uff0c\u4e00\u6b21\u6027\u52a0\u8f7d\u5168\u90e8\u56fe\u7247\uff0c\u4f1a\u5bf9\u7528\u6237\u4f53\u9a8c\u9020\u6210\u5f88\u5927\u7684\u5f71\u54cd\uff0c\u6240\u4ee5\u9700\u8981\u4f7f\u7528\u56fe\u7247\u5ef6\u8fdf\u52a0\u8f7d\u3002<\/p>\n<p>\u9996\u5148\u53ef\u4ee5\u5c06\u56fe\u7247\u8fd9\u6837\u8bbe\u7f6e\uff0c\u5728\u9875\u9762\u4e0d\u53ef\u89c1\u65f6\u56fe\u7247\u4e0d\u4f1a\u52a0\u8f7d\uff1a<\/p>\n<pre class=\"xml hljs\"><code class=\"html\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">img<\/span>\u00a0<span class=\"hljs-attr\">data-src<\/span>=<span class=\"hljs-string\">\"https:\/\/avatars0.githubusercontent.com\/u\/22117876?s=460&amp;u=7bd8f32788df6988833da6bd155c3cfbebc68006&amp;v=4\"<\/span>&gt;<\/span><\/code><\/pre>\n<p>\u7b49\u9875\u9762\u53ef\u89c1\u65f6\uff0c\u4f7f\u7528 JS \u52a0\u8f7d\u56fe\u7247\uff1a<\/p>\n<pre class=\"javascript hljs\"><code class=\"js\"><span class=\"hljs-keyword\">const<\/span> img = <span class=\"hljs-built_in\">document<\/span>.querySelector(<span class=\"hljs-string\">'img'<\/span>)\r\nimg.src = img.dataset.src<\/code><\/pre>\n<p>\u8fd9\u6837\u56fe\u7247\u5c31\u52a0\u8f7d\u51fa\u6765\u4e86\uff0c\u5b8c\u6574\u7684\u4ee3\u7801\u53ef\u4ee5\u770b\u4e00\u4e0b\u53c2\u8003\u8d44\u6599\u3002<\/p>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/juejin.im\/entry\/594a483061ff4b006c12cea1\" target=\"_blank\" rel=\"nofollow noreferrer\">web \u524d\u7aef\u56fe\u7247\u61d2\u52a0\u8f7d\u5b9e\u73b0\u539f\u7406<\/a><\/li>\n<\/ul>\n<p><strong>(2). \u54cd\u5e94\u5f0f\u56fe\u7247<\/strong><br \/>\n\u54cd\u5e94\u5f0f\u56fe\u7247\u7684\u4f18\u70b9\u662f\u6d4f\u89c8\u5668\u80fd\u591f\u6839\u636e\u5c4f\u5e55\u5927\u5c0f\u81ea\u52a8\u52a0\u8f7d\u5408\u9002\u7684\u56fe\u7247\u3002<\/p>\n<p>\u901a\u8fc7\u00a0<code>picture<\/code>\u00a0\u5b9e\u73b0<\/p>\n<pre class=\"xml hljs\"><code class=\"html\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">picture<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">source<\/span> <span class=\"hljs-attr\">srcset<\/span>=<span class=\"hljs-string\">\"banner_w1000.jpg\"<\/span> <span class=\"hljs-attr\">media<\/span>=<span class=\"hljs-string\">\"(min-width: 801px)\"<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">source<\/span> <span class=\"hljs-attr\">srcset<\/span>=<span class=\"hljs-string\">\"banner_w800.jpg\"<\/span> <span class=\"hljs-attr\">media<\/span>=<span class=\"hljs-string\">\"(max-width: 800px)\"<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">img<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">\"banner_w800.jpg\"<\/span> <span class=\"hljs-attr\">alt<\/span>=<span class=\"hljs-string\">\"\"<\/span>&gt;<\/span>\r\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">picture<\/span>&gt;<\/span><\/code><\/pre>\n<p>\u901a\u8fc7\u00a0<code>@media<\/code>\u00a0\u5b9e\u73b0<\/p>\n<pre class=\"xml hljs\"><code class=\"html\">@media (min-width: 769px) {\r\n    .bg {\r\n        background-image: url(bg1080.jpg);\r\n    }\r\n}\r\n@media (max-width: 768px) {\r\n    .bg {\r\n        background-image: url(bg768.jpg);\r\n    }\r\n}<\/code><\/pre>\n<p><strong>(3). \u8c03\u6574\u56fe\u7247\u5927\u5c0f<\/strong><br \/>\n\u4f8b\u5982\uff0c\u4f60\u6709\u4e00\u4e2a 1920 * 1080 \u5927\u5c0f\u7684\u56fe\u7247\uff0c\u7528\u7f29\u7565\u56fe\u7684\u65b9\u5f0f\u5c55\u793a\u7ed9\u7528\u6237\uff0c\u5e76\u4e14\u5f53\u7528\u6237\u9f20\u6807\u60ac\u505c\u5728\u4e0a\u9762\u65f6\u624d\u5c55\u793a\u5168\u56fe\u3002\u5982\u679c\u7528\u6237\u4ece\u672a\u771f\u6b63\u5c06\u9f20\u6807\u60ac\u505c\u5728\u7f29\u7565\u56fe\u4e0a\uff0c\u5219\u6d6a\u8d39\u4e86\u4e0b\u8f7d\u56fe\u7247\u7684\u65f6\u95f4\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u6211\u4eec\u53ef\u4ee5\u7528\u4e24\u5f20\u56fe\u7247\u6765\u5b9e\u884c\u4f18\u5316\u3002\u4e00\u5f00\u59cb\uff0c\u53ea\u52a0\u8f7d\u7f29\u7565\u56fe\uff0c\u5f53\u7528\u6237\u60ac\u505c\u5728\u56fe\u7247\u4e0a\u65f6\uff0c\u624d\u52a0\u8f7d\u5927\u56fe\u3002\u8fd8\u6709\u4e00\u79cd\u529e\u6cd5\uff0c\u5373\u5bf9\u5927\u56fe\u8fdb\u884c\u5ef6\u8fdf\u52a0\u8f7d\uff0c\u5728\u6240\u6709\u5143\u7d20\u90fd\u52a0\u8f7d\u5b8c\u6210\u540e\u624b\u52a8\u66f4\u6539\u5927\u56fe\u7684 src \u8fdb\u884c\u4e0b\u8f7d\u3002<\/p>\n<p><strong>(4). \u964d\u4f4e\u56fe\u7247\u8d28\u91cf<\/strong><br \/>\n\u4f8b\u5982 JPG \u683c\u5f0f\u7684\u56fe\u7247\uff0c100% \u7684\u8d28\u91cf\u548c 90% \u8d28\u91cf\u7684\u901a\u5e38\u770b\u4e0d\u51fa\u6765\u533a\u522b\uff0c\u5c24\u5176\u662f\u7528\u6765\u5f53\u80cc\u666f\u56fe\u7684\u65f6\u5019\u3002\u6211\u7ecf\u5e38\u7528 PS \u5207\u80cc\u666f\u56fe\u65f6\uff0c \u5c06\u56fe\u7247\u5207\u6210 JPG \u683c\u5f0f\uff0c\u5e76\u4e14\u5c06\u5b83\u538b\u7f29\u5230 60% \u7684\u8d28\u91cf\uff0c\u57fa\u672c\u4e0a\u770b\u4e0d\u51fa\u6765\u533a\u522b\u3002<\/p>\n<p>\u9664\u6b64\u4e4b\u5916\uff0c\u7f51\u4e0a\u8fd8\u6709\u5f88\u591a\u5728\u7ebf\u538b\u7f29\u56fe\u7247\u7684\u7f51\u7ad9\uff0c\u5927\u5bb6\u53ef\u4ee5\u81ea\u884c\u641c\u7d22\u3002<\/p>\n<p><strong>(5). \u5c3d\u53ef\u80fd\u5229\u7528 CSS3 \u6548\u679c\u4ee3\u66ff\u56fe\u7247<\/strong><br \/>\n\u6709\u5f88\u591a\u56fe\u7247\u4f7f\u7528 CSS \u6548\u679c\uff08\u6e10\u53d8\u3001\u9634\u5f71\u7b49\uff09\u5c31\u80fd\u753b\u51fa\u6765\uff0c\u8fd9\u79cd\u60c5\u51b5\u9009\u62e9 CSS3 \u6548\u679c\u66f4\u597d\u3002\u56e0\u4e3a\u4ee3\u7801\u5927\u5c0f\u901a\u5e38\u662f\u56fe\u7247\u5927\u5c0f\u7684\u51e0\u5206\u4e4b\u4e00\u751a\u81f3\u51e0\u5341\u5206\u4e4b\u4e00\u3002<\/p>\n<h4>10. \u901a\u8fc7 webpack \u6309\u9700\u52a0\u8f7d JavaScript \u4ee3\u7801<\/h4>\n<blockquote><p>\u61d2\u52a0\u8f7d\u6216\u8005\u6309\u9700\u52a0\u8f7d\uff0c\u662f\u4e00\u79cd\u5f88\u597d\u7684\u4f18\u5316\u7f51\u9875\u6216\u5e94\u7528\u7684\u65b9\u5f0f\u3002\u8fd9\u79cd\u65b9\u5f0f\u5b9e\u9645\u4e0a\u662f\u5148\u628a\u4f60\u7684\u4ee3\u7801\u5728\u4e00\u4e9b\u903b\u8f91\u65ad\u70b9\u5904\u5206\u79bb\u5f00\uff0c\u7136\u540e\u5728\u4e00\u4e9b\u4ee3\u7801\u5757\u4e2d\u5b8c\u6210\u67d0\u4e9b\u64cd\u4f5c\u540e\uff0c\u7acb\u5373\u5f15\u7528\u6216\u5373\u5c06\u5f15\u7528\u53e6\u5916\u4e00\u4e9b\u65b0\u7684\u4ee3\u7801\u5757\u3002\u8fd9\u6837\u52a0\u5feb\u4e86\u5e94\u7528\u7684\u521d\u59cb\u52a0\u8f7d\u901f\u5ea6\uff0c\u51cf\u8f7b\u4e86\u5b83\u7684\u603b\u4f53\u4f53\u79ef\uff0c\u56e0\u4e3a\u67d0\u4e9b\u4ee3\u7801\u5757\u53ef\u80fd\u6c38\u8fdc\u4e0d\u4f1a\u88ab\u52a0\u8f7d\u3002<\/p><\/blockquote>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u811a\u624b\u67b6\u6765\u6784\u5efa\u9879\u76ee\uff0c\u4e00\u822c\u914d\u7f6e\u8d77\u6765\u975e\u5e38\u7b80\u5355\uff0c\u5177\u4f53\u7ec6\u8282\u53ef\u770b\u4e00\u4e0b webpack \u6587\u6863\u3002<\/p>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n<ul>\n<li><a href=\"http:\/\/webpack.docschina.org\/guides\/lazy-loading\/\" target=\"_blank\" rel=\"nofollow noreferrer\">\u61d2\u52a0\u8f7d<\/a><\/li>\n<li><a href=\"https:\/\/router.vuejs.org\/zh\/guide\/advanced\/lazy-loading.html#%E8%B7%AF%E7%94%B1%E6%87%92%E5%8A%A0%E8%BD%BD\" target=\"_blank\" rel=\"nofollow noreferrer\">Vue \u8def\u7531\u61d2\u52a0\u8f7d<\/a><\/li>\n<\/ul>\n<h4>11. \u51cf\u5c11\u91cd\u7ed8\u91cd\u6392<\/h4>\n<p><strong>\u6d4f\u89c8\u5668\u6e32\u67d3\u8fc7\u7a0b<\/strong><\/p>\n<ol>\n<li>\u89e3\u6790HTML\u751f\u6210DOM\u6811\u3002<\/li>\n<li>\u89e3\u6790CSS\u751f\u6210CSSOM\u89c4\u5219\u6811\u3002<\/li>\n<li>\u5c06DOM\u6811\u4e0eCSSOM\u89c4\u5219\u6811\u5408\u5e76\u5728\u4e00\u8d77\u751f\u6210\u6e32\u67d3\u6811\u3002<\/li>\n<li>\u904d\u5386\u6e32\u67d3\u6811\u5f00\u59cb\u5e03\u5c40\uff0c\u8ba1\u7b97\u6bcf\u4e2a\u8282\u70b9\u7684\u4f4d\u7f6e\u5927\u5c0f\u4fe1\u606f\u3002<\/li>\n<li>\u5c06\u6e32\u67d3\u6811\u6bcf\u4e2a\u8282\u70b9\u7ed8\u5236\u5230\u5c4f\u5e55\u3002<\/li>\n<\/ol>\n<p><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/QQ\u255c\u256a\u2550\u255d20200413202534.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2617\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/QQ\u255c\u256a\u2550\u255d20200413202534.png\" alt=\"QQ\u255c\u256a\u2550\u255d20200413202534\" width=\"646\" height=\"302\" \/><\/a><\/p>\n<p><strong>\u91cd\u6392<\/strong><br \/>\n\u5f53\u6539\u53d8 DOM \u5143\u7d20\u4f4d\u7f6e\u6216\u5927\u5c0f\u65f6\uff0c\u4f1a\u5bfc\u81f4\u6d4f\u89c8\u5668\u91cd\u65b0\u751f\u6210\u6e32\u67d3\u6811\uff0c\u8fd9\u4e2a\u8fc7\u7a0b\u53eb\u91cd\u6392\u3002<\/p>\n<p><strong>\u91cd\u7ed8<\/strong><br \/>\n\u5f53\u91cd\u65b0\u751f\u6210\u6e32\u67d3\u6811\u540e\uff0c\u5c31\u8981\u5c06\u6e32\u67d3\u6811\u6bcf\u4e2a\u8282\u70b9\u7ed8\u5236\u5230\u5c4f\u5e55\uff0c\u8fd9\u4e2a\u8fc7\u7a0b\u53eb\u91cd\u7ed8\u3002\u4e0d\u662f\u6240\u6709\u7684\u52a8\u4f5c\u90fd\u4f1a\u5bfc\u81f4\u91cd\u6392\uff0c\u4f8b\u5982\u6539\u53d8\u5b57\u4f53\u989c\u8272\uff0c\u53ea\u4f1a\u5bfc\u81f4\u91cd\u7ed8\u3002\u8bb0\u4f4f\uff0c\u91cd\u6392\u4f1a\u5bfc\u81f4\u91cd\u7ed8\uff0c\u91cd\u7ed8\u4e0d\u4f1a\u5bfc\u81f4\u91cd\u6392 \u3002<\/p>\n<p>\u91cd\u6392\u548c\u91cd\u7ed8\u8fd9\u4e24\u4e2a\u64cd\u4f5c\u90fd\u662f\u975e\u5e38\u6602\u8d35\u7684\uff0c\u56e0\u4e3a JavaScript \u5f15\u64ce\u7ebf\u7a0b\u4e0e GUI \u6e32\u67d3\u7ebf\u7a0b\u662f\u4e92\u65a5\uff0c\u5b83\u4eec\u540c\u65f6\u53ea\u80fd\u4e00\u4e2a\u5728\u5de5\u4f5c\u3002<\/p>\n<p>\u4ec0\u4e48\u64cd\u4f5c\u4f1a\u5bfc\u81f4\u91cd\u6392\uff1f<\/p>\n<ul>\n<li>\u6dfb\u52a0\u6216\u5220\u9664\u53ef\u89c1\u7684 DOM \u5143\u7d20<\/li>\n<li>\u5143\u7d20\u4f4d\u7f6e\u6539\u53d8<\/li>\n<li>\u5143\u7d20\u5c3a\u5bf8\u6539\u53d8<\/li>\n<li>\u5185\u5bb9\u6539\u53d8<\/li>\n<li>\u6d4f\u89c8\u5668\u7a97\u53e3\u5c3a\u5bf8\u6539\u53d8<\/li>\n<\/ul>\n<p>\u5982\u4f55\u51cf\u5c11\u91cd\u6392\u91cd\u7ed8\uff1f<\/p>\n<ul>\n<li>\u7528 JavaScript \u4fee\u6539\u6837\u5f0f\u65f6\uff0c\u6700\u597d\u4e0d\u8981\u76f4\u63a5\u5199\u6837\u5f0f\uff0c\u800c\u662f\u66ff\u6362 class \u6765\u6539\u53d8\u6837\u5f0f\u3002<\/li>\n<li>\u5982\u679c\u8981\u5bf9 DOM \u5143\u7d20\u6267\u884c\u4e00\u7cfb\u5217\u64cd\u4f5c\uff0c\u53ef\u4ee5\u5c06 DOM \u5143\u7d20\u8131\u79bb\u6587\u6863\u6d41\uff0c\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u518d\u5c06\u5b83\u5e26\u56de\u6587\u6863\u3002\u63a8\u8350\u4f7f\u7528\u9690\u85cf\u5143\u7d20\uff08display:none\uff09\u6216\u6587\u6863\u788e\u7247\uff08DocumentFragement\uff09\uff0c\u90fd\u80fd\u5f88\u597d\u7684\u5b9e\u73b0\u8fd9\u4e2a\u65b9\u6848\u3002<\/li>\n<\/ul>\n<h4>12. \u4f7f\u7528\u4e8b\u4ef6\u59d4\u6258<\/h4>\n<p>\u4e8b\u4ef6\u59d4\u6258\u5229\u7528\u4e86\u4e8b\u4ef6\u5192\u6ce1\uff0c\u53ea\u6307\u5b9a\u4e00\u4e2a\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\uff0c\u5c31\u53ef\u4ee5\u7ba1\u7406\u67d0\u4e00\u7c7b\u578b\u7684\u6240\u6709\u4e8b\u4ef6\u3002\u6240\u6709\u7528\u5230\u6309\u94ae\u7684\u4e8b\u4ef6\uff08\u591a\u6570\u9f20\u6807\u4e8b\u4ef6\u548c\u952e\u76d8\u4e8b\u4ef6\uff09\u90fd\u9002\u5408\u91c7\u7528\u4e8b\u4ef6\u59d4\u6258\u6280\u672f\uff0c \u4f7f\u7528\u4e8b\u4ef6\u59d4\u6258\u53ef\u4ee5\u8282\u7701\u5185\u5b58\u3002<\/p>\n<pre class=\"javascript hljs\"><code class=\"js\">&lt;ul&gt;\r\n  <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">li<\/span>&gt;<\/span>\u82f9\u679c<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">li<\/span>&gt;<\/span><\/span>\r\n  <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">li<\/span>&gt;<\/span>\u9999\u8549<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">li<\/span>&gt;<\/span><\/span>\r\n  <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">li<\/span>&gt;<\/span>\u51e4\u68a8<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">li<\/span>&gt;<\/span><\/span>\r\n&lt;<span class=\"hljs-regexp\">\/ul&gt;\r\n\r\n\/<\/span><span class=\"hljs-regexp\">\/ good\r\ndocument.querySelector('ul').onclick = (event) =&gt; {\r\n  const target = event.target\r\n  if (target.nodeName === 'LI') {\r\n    console.log(target.innerHTML)\r\n  }\r\n}\r\n\r\n\/<\/span><span class=\"hljs-regexp\">\/ bad\r\ndocument.querySelectorAll('li').forEach((e) =&gt; {\r\n  e.onclick = function() {\r\n    console.log(this.innerHTML)\r\n  }\r\n}) <\/span><\/code><\/pre>\n<h4>13. \u6ce8\u610f\u7a0b\u5e8f\u7684\u5c40\u90e8\u6027<\/h4>\n<p>\u4e00\u4e2a\u7f16\u5199\u826f\u597d\u7684\u8ba1\u7b97\u673a\u7a0b\u5e8f\u5e38\u5e38\u5177\u6709\u826f\u597d\u7684\u5c40\u90e8\u6027\uff0c\u5b83\u4eec\u503e\u5411\u4e8e\u5f15\u7528\u6700\u8fd1\u5f15\u7528\u8fc7\u7684\u6570\u636e\u9879\u9644\u8fd1\u7684\u6570\u636e\u9879\uff0c\u6216\u8005\u6700\u8fd1\u5f15\u7528\u8fc7\u7684\u6570\u636e\u9879\u672c\u8eab\uff0c\u8fd9\u79cd\u503e\u5411\u6027\uff0c\u88ab\u79f0\u4e3a\u5c40\u90e8\u6027\u539f\u7406\u3002\u6709\u826f\u597d\u5c40\u90e8\u6027\u7684\u7a0b\u5e8f\u6bd4\u5c40\u90e8\u6027\u5dee\u7684\u7a0b\u5e8f\u8fd0\u884c\u5f97\u66f4\u5feb\u3002<\/p>\n<p><strong>\u5c40\u90e8\u6027\u901a\u5e38\u6709\u4e24\u79cd\u4e0d\u540c\u7684\u5f62\u5f0f\uff1a<\/strong><\/p>\n<ul>\n<li>\u65f6\u95f4\u5c40\u90e8\u6027\uff1a\u5728\u4e00\u4e2a\u5177\u6709\u826f\u597d\u65f6\u95f4\u5c40\u90e8\u6027\u7684\u7a0b\u5e8f\u4e2d\uff0c\u88ab\u5f15\u7528\u8fc7\u4e00\u6b21\u7684\u5185\u5b58\u4f4d\u7f6e\u5f88\u53ef\u80fd\u5728\u4e0d\u8fdc\u7684\u5c06\u6765\u88ab\u591a\u6b21\u5f15\u7528\u3002<\/li>\n<li>\u7a7a\u95f4\u5c40\u90e8\u6027 \uff1a\u5728\u4e00\u4e2a\u5177\u6709\u826f\u597d\u7a7a\u95f4\u5c40\u90e8\u6027\u7684\u7a0b\u5e8f\u4e2d\uff0c\u5982\u679c\u4e00\u4e2a\u5185\u5b58\u4f4d\u7f6e\u88ab\u5f15\u7528\u4e86\u4e00\u6b21\uff0c\u90a3\u4e48\u7a0b\u5e8f\u5f88\u53ef\u80fd\u5728\u4e0d\u8fdc\u7684\u5c06\u6765\u5f15\u7528\u9644\u8fd1\u7684\u4e00\u4e2a\u5185\u5b58\u4f4d\u7f6e\u3002<\/li>\n<\/ul>\n<p>\u65f6\u95f4\u5c40\u90e8\u6027\u793a\u4f8b<\/p>\n<pre class=\"hljs matlab\"><code><span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">sum<\/span><span class=\"hljs-params\">(arry)<\/span> {<\/span>\r\n    let <span class=\"hljs-built_in\">i<\/span>, sum = <span class=\"hljs-number\">0<\/span>\r\n    let len = arry.<span class=\"hljs-built_in\">length<\/span>\r\n\r\n    <span class=\"hljs-keyword\">for<\/span> (<span class=\"hljs-built_in\">i<\/span> = <span class=\"hljs-number\">0<\/span>; <span class=\"hljs-built_in\">i<\/span> &lt; len; <span class=\"hljs-built_in\">i<\/span>++) {\r\n        sum += arry[<span class=\"hljs-built_in\">i<\/span>]\r\n    }\r\n\r\n    <span class=\"hljs-keyword\">return<\/span> sum\r\n}<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u53d8\u91cfsum\u5728\u6bcf\u6b21\u5faa\u73af\u8fed\u4ee3\u4e2d\u88ab\u5f15\u7528\u4e00\u6b21\uff0c\u56e0\u6b64\uff0c\u5bf9\u4e8esum\u6765\u8bf4\uff0c\u5177\u6709\u826f\u597d\u7684\u65f6\u95f4\u5c40\u90e8\u6027<\/p>\n<p>\u7a7a\u95f4\u5c40\u90e8\u6027\u793a\u4f8b<\/p>\n<p><strong>\u5177\u6709\u826f\u597d\u7a7a\u95f4\u5c40\u90e8\u6027\u7684\u7a0b\u5e8f<\/strong><\/p>\n<pre class=\"hljs javascript\"><code><span class=\"hljs-comment\">\/\/ \u4e8c\u7ef4\u6570\u7ec4 <\/span>\r\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">sum1<\/span>(<span class=\"hljs-params\">arry, rows, cols<\/span>) <\/span>{\r\n    <span class=\"hljs-keyword\">let<\/span> i, j, sum = <span class=\"hljs-number\">0<\/span>\r\n\r\n    <span class=\"hljs-keyword\">for<\/span> (i = <span class=\"hljs-number\">0<\/span>; i &lt; rows; i++) {\r\n        <span class=\"hljs-keyword\">for<\/span> (j = <span class=\"hljs-number\">0<\/span>; j &lt; cols; j++) {\r\n            sum += arry[i][j]\r\n        }\r\n    }\r\n    <span class=\"hljs-keyword\">return<\/span> sum\r\n}<\/code><\/pre>\n<p><strong>\u7a7a\u95f4\u5c40\u90e8\u6027\u5dee\u7684\u7a0b\u5e8f<\/strong><\/p>\n<pre class=\"hljs javascript\"><code><span class=\"hljs-comment\">\/\/ \u4e8c\u7ef4\u6570\u7ec4 <\/span>\r\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">sum2<\/span>(<span class=\"hljs-params\">arry, rows, cols<\/span>) <\/span>{\r\n    <span class=\"hljs-keyword\">let<\/span> i, j, sum = <span class=\"hljs-number\">0<\/span>\r\n\r\n    <span class=\"hljs-keyword\">for<\/span> (j = <span class=\"hljs-number\">0<\/span>; j &lt; cols; j++) {\r\n        <span class=\"hljs-keyword\">for<\/span> (i = <span class=\"hljs-number\">0<\/span>; i &lt; rows; i++) {\r\n            sum += arry[i][j]\r\n        }\r\n    }\r\n    <span class=\"hljs-keyword\">return<\/span> sum\r\n}<\/code><\/pre>\n<p>\u770b\u4e00\u4e0b\u4e0a\u9762\u7684\u4e24\u4e2a\u7a7a\u95f4\u5c40\u90e8\u6027\u793a\u4f8b\uff0c\u50cf\u793a\u4f8b\u4e2d\u4ece\u6bcf\u884c\u5f00\u59cb\u6309\u987a\u5e8f\u8bbf\u95ee\u6570\u7ec4\u6bcf\u4e2a\u5143\u7d20\u7684\u65b9\u5f0f\uff0c\u79f0\u4e3a\u5177\u6709\u6b65\u957f\u4e3a1\u7684\u5f15\u7528\u6a21\u5f0f\u3002<br \/>\n\u5982\u679c\u5728\u6570\u7ec4\u4e2d\uff0c\u6bcf\u9694k\u4e2a\u5143\u7d20\u8fdb\u884c\u8bbf\u95ee\uff0c\u5c31\u79f0\u4e3a\u6b65\u957f\u4e3ak\u7684\u5f15\u7528\u6a21\u5f0f\u3002<br \/>\n\u4e00\u822c\u800c\u8a00\uff0c\u968f\u7740\u6b65\u957f\u7684\u589e\u52a0\uff0c\u7a7a\u95f4\u5c40\u90e8\u6027\u4e0b\u964d\u3002<\/p>\n<p>\u8fd9\u4e24\u4e2a\u4f8b\u5b50\u6709\u4ec0\u4e48\u533a\u522b\uff1f\u533a\u522b\u5728\u4e8e\u7b2c\u4e00\u4e2a\u793a\u4f8b\u662f\u6309\u884c\u626b\u63cf\u6570\u7ec4\uff0c\u6bcf\u626b\u63cf\u5b8c\u4e00\u884c\u518d\u53bb\u626b\u4e0b\u4e00\u884c\uff1b\u7b2c\u4e8c\u4e2a\u793a\u4f8b\u662f\u6309\u5217\u6765\u626b\u63cf\u6570\u7ec4\uff0c\u626b\u5b8c\u4e00\u884c\u4e2d\u7684\u4e00\u4e2a\u5143\u7d20\uff0c\u9a6c\u4e0a\u5c31\u53bb\u626b\u4e0b\u4e00\u884c\u4e2d\u7684\u540c\u4e00\u5217\u5143\u7d20\u3002<\/p>\n<p>\u6570\u7ec4\u5728\u5185\u5b58\u4e2d\u662f\u6309\u7167\u884c\u987a\u5e8f\u6765\u5b58\u653e\u7684\uff0c\u7ed3\u679c\u5c31\u662f\u9010\u884c\u626b\u63cf\u6570\u7ec4\u7684\u793a\u4f8b\u5f97\u5230\u4e86\u6b65\u957f\u4e3a 1 \u5f15\u7528\u6a21\u5f0f\uff0c\u5177\u6709\u826f\u597d\u7684\u7a7a\u95f4\u5c40\u90e8\u6027\uff1b\u800c\u53e6\u4e00\u4e2a\u793a\u4f8b\u6b65\u957f\u4e3a rows\uff0c\u7a7a\u95f4\u5c40\u90e8\u6027\u6781\u5dee\u3002<\/p>\n<p><strong>\u6027\u80fd\u6d4b\u8bd5<\/strong><br \/>\n\u8fd0\u884c\u73af\u5883\uff1a<\/p>\n<ul>\n<li>cpu: i5-7400<\/li>\n<li>\u6d4f\u89c8\u5668: chrome 70.0.3538.110<\/li>\n<\/ul>\n<p>\u5bf9\u4e00\u4e2a\u957f\u5ea6\u4e3a9000\u7684\u4e8c\u7ef4\u6570\u7ec4\uff08\u5b50\u6570\u7ec4\u957f\u5ea6\u4e5f\u4e3a9000\uff09\u8fdb\u884c10\u6b21\u7a7a\u95f4\u5c40\u90e8\u6027\u6d4b\u8bd5\uff0c\u65f6\u95f4\uff08\u6beb\u79d2\uff09\u53d6\u5e73\u5747\u503c\uff0c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<p>\u6240\u7528\u793a\u4f8b\u4e3a\u4e0a\u8ff0\u4e24\u4e2a\u7a7a\u95f4\u5c40\u90e8\u6027\u793a\u4f8b<\/p>\n<div>\n<table>\n<thead>\n<tr>\n<th>\u6b65\u957f\u4e3a 1<\/th>\n<th>\u6b65\u957f\u4e3a 9000<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>124<\/td>\n<td>2316<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u4ece\u4ee5\u4e0a\u6d4b\u8bd5\u7ed3\u679c\u6765\u770b\uff0c\u6b65\u957f\u4e3a 1 \u7684\u6570\u7ec4\u6267\u884c\u65f6\u95f4\u6bd4\u6b65\u957f\u4e3a 9000 \u7684\u6570\u7ec4\u5feb\u4e86\u4e00\u4e2a\u6570\u91cf\u7ea7\u3002<\/p>\n<p>\u603b\u7ed3\uff1a<\/p>\n<ul>\n<li>\u91cd\u590d\u5f15\u7528\u76f8\u540c\u53d8\u91cf\u7684\u7a0b\u5e8f\u5177\u6709\u826f\u597d\u7684\u65f6\u95f4\u5c40\u90e8\u6027<\/li>\n<li>\u5bf9\u4e8e\u5177\u6709\u6b65\u957f\u4e3a k \u7684\u5f15\u7528\u6a21\u5f0f\u7684\u7a0b\u5e8f\uff0c\u6b65\u957f\u8d8a\u5c0f\uff0c\u7a7a\u95f4\u5c40\u90e8\u6027\u8d8a\u597d\uff1b\u800c\u5728\u5185\u5b58\u4e2d\u4ee5\u5927\u6b65\u957f\u8df3\u6765\u8df3\u53bb\u7684\u7a0b\u5e8f\u7a7a\u95f4\u5c40\u90e8\u6027\u4f1a\u5f88\u5dee<\/li>\n<\/ul>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/book.douban.com\/subject\/26912767\/\" target=\"_blank\" rel=\"nofollow noreferrer\">\u6df1\u5165\u7406\u89e3\u8ba1\u7b97\u673a\u7cfb\u7edf<\/a><\/li>\n<\/ul>\n<h4>14. if-else \u5bf9\u6bd4 switch<\/h4>\n<p>\u5f53\u5224\u65ad\u6761\u4ef6\u6570\u91cf\u8d8a\u6765\u8d8a\u591a\u65f6\uff0c\u8d8a\u503e\u5411\u4e8e\u4f7f\u7528 switch \u800c\u4e0d\u662f if-else\u3002<\/p>\n<pre class=\"javascript hljs\"><code class=\"js\"><span class=\"hljs-keyword\">if<\/span> (color == <span class=\"hljs-string\">'blue'<\/span>) {\r\n\r\n} <span class=\"hljs-keyword\">else<\/span> <span class=\"hljs-keyword\">if<\/span> (color == <span class=\"hljs-string\">'yellow'<\/span>) {\r\n\r\n} <span class=\"hljs-keyword\">else<\/span> <span class=\"hljs-keyword\">if<\/span> (color == <span class=\"hljs-string\">'white'<\/span>) {\r\n\r\n} <span class=\"hljs-keyword\">else<\/span> <span class=\"hljs-keyword\">if<\/span> (color == <span class=\"hljs-string\">'black'<\/span>) {\r\n\r\n} <span class=\"hljs-keyword\">else<\/span> <span class=\"hljs-keyword\">if<\/span> (color == <span class=\"hljs-string\">'green'<\/span>) {\r\n\r\n} <span class=\"hljs-keyword\">else<\/span> <span class=\"hljs-keyword\">if<\/span> (color == <span class=\"hljs-string\">'orange'<\/span>) {\r\n\r\n} <span class=\"hljs-keyword\">else<\/span> <span class=\"hljs-keyword\">if<\/span> (color == <span class=\"hljs-string\">'pink'<\/span>) {\r\n\r\n}\r\n\r\n<span class=\"hljs-keyword\">switch<\/span> (color) {\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'blue'<\/span>:\r\n\r\n        <span class=\"hljs-keyword\">break<\/span>\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'yellow'<\/span>:\r\n\r\n        <span class=\"hljs-keyword\">break<\/span>\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'white'<\/span>:\r\n\r\n        <span class=\"hljs-keyword\">break<\/span>\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'black'<\/span>:\r\n\r\n        <span class=\"hljs-keyword\">break<\/span>\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'green'<\/span>:\r\n\r\n        <span class=\"hljs-keyword\">break<\/span>\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'orange'<\/span>:\r\n\r\n        <span class=\"hljs-keyword\">break<\/span>\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'pink'<\/span>:\r\n\r\n        <span class=\"hljs-keyword\">break<\/span>\r\n}<\/code><\/pre>\n<p>\u50cf\u4ee5\u4e0a\u8fd9\u79cd\u60c5\u51b5\uff0c\u4f7f\u7528 switch \u662f\u6700\u597d\u7684\u3002\u5047\u8bbe color \u7684\u503c\u4e3a pink\uff0c\u5219 if-else \u8bed\u53e5\u8981\u8fdb\u884c 7 \u6b21\u5224\u65ad\uff0cswitch \u53ea\u9700\u8981\u8fdb\u884c\u4e00\u6b21\u5224\u65ad\u3002<br \/>\n\u4ece\u53ef\u8bfb\u6027\u6765\u8bf4\uff0cswitch \u8bed\u53e5\u4e5f\u66f4\u597d\u3002\u4ece\u4f7f\u7528\u65f6\u673a\u6765\u8bf4\uff0c\u5f53\u6761\u4ef6\u503c\u5927\u4e8e\u4e24\u4e2a\u7684\u65f6\u5019\uff0c\u4f7f\u7528 switch \u66f4\u597d\u3002<\/p>\n<p>\u4e0d\u8fc7\uff0cswitch \u53ea\u80fd\u7528\u4e8e case \u503c\u4e3a\u5e38\u91cf\u7684\u5206\u652f\u7ed3\u6784\uff0c\u800c if-else \u66f4\u52a0\u7075\u6d3b\u3002<\/p>\n<h4>15. \u67e5\u627e\u8868<\/h4>\n<p>\u5f53\u6761\u4ef6\u8bed\u53e5\u7279\u522b\u591a\u65f6\uff0c\u4f7f\u7528 switch \u548c if-else \u4e0d\u662f\u6700\u4f73\u7684\u9009\u62e9\uff0c\u8fd9\u65f6\u4e0d\u59a8\u8bd5\u4e00\u4e0b\u67e5\u627e\u8868\u3002\u67e5\u627e\u8868\u53ef\u4ee5\u4f7f\u7528\u6570\u7ec4\u548c\u5bf9\u8c61\u6765\u6784\u5efa\u3002<\/p>\n<pre class=\"javascript hljs\"><code class=\"js\"><span class=\"hljs-keyword\">switch<\/span> (index) {\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'0'<\/span>:\r\n        <span class=\"hljs-keyword\">return<\/span> result0\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'1'<\/span>:\r\n        <span class=\"hljs-keyword\">return<\/span> result1\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'2'<\/span>:\r\n        <span class=\"hljs-keyword\">return<\/span> result2\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'3'<\/span>:\r\n        <span class=\"hljs-keyword\">return<\/span> result3\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'4'<\/span>:\r\n        <span class=\"hljs-keyword\">return<\/span> result4\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'5'<\/span>:\r\n        <span class=\"hljs-keyword\">return<\/span> result5\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'6'<\/span>:\r\n        <span class=\"hljs-keyword\">return<\/span> result6\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'7'<\/span>:\r\n        <span class=\"hljs-keyword\">return<\/span> result7\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'8'<\/span>:\r\n        <span class=\"hljs-keyword\">return<\/span> result8\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'9'<\/span>:\r\n        <span class=\"hljs-keyword\">return<\/span> result9\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'10'<\/span>:\r\n        <span class=\"hljs-keyword\">return<\/span> result10\r\n    <span class=\"hljs-keyword\">case<\/span> <span class=\"hljs-string\">'11'<\/span>:\r\n        <span class=\"hljs-keyword\">return<\/span> result11\r\n}<\/code><\/pre>\n<p>\u53ef\u4ee5\u5c06\u8fd9\u4e2a switch \u8bed\u53e5\u8f6c\u6362\u4e3a\u67e5\u627e\u8868<\/p>\n<pre class=\"javascript hljs\"><code class=\"js\"><span class=\"hljs-keyword\">const<\/span> results = [result0,result1,result2,result3,result4,result5,result6,result7,result8,result9,result10,result11]\r\n\r\n<span class=\"hljs-keyword\">return<\/span> results[index]<\/code><\/pre>\n<p>\u5982\u679c\u6761\u4ef6\u8bed\u53e5\u4e0d\u662f\u6570\u503c\u800c\u662f\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u7528\u5bf9\u8c61\u6765\u5efa\u7acb\u67e5\u627e\u8868<\/p>\n<pre class=\"javascript hljs\"><code class=\"js\"><span class=\"hljs-keyword\">const<\/span> map = {\r\n  <span class=\"hljs-attr\">red<\/span>: result0,\r\n  <span class=\"hljs-attr\">green<\/span>: result1,\r\n}\r\n\r\n<span class=\"hljs-keyword\">return<\/span> map[color]<\/code><\/pre>\n<h4>16. \u907f\u514d\u9875\u9762\u5361\u987f<\/h4>\n<p><strong>60fps \u4e0e\u8bbe\u5907\u5237\u65b0\u7387<\/strong><\/p>\n<blockquote><p>\u76ee\u524d\u5927\u591a\u6570\u8bbe\u5907\u7684\u5c4f\u5e55\u5237\u65b0\u7387\u4e3a 60 \u6b21\/\u79d2\u3002\u56e0\u6b64\uff0c\u5982\u679c\u5728\u9875\u9762\u4e2d\u6709\u4e00\u4e2a\u52a8\u753b\u6216\u6e10\u53d8\u6548\u679c\uff0c\u6216\u8005\u7528\u6237\u6b63\u5728\u6eda\u52a8\u9875\u9762\uff0c\u90a3\u4e48\u6d4f\u89c8\u5668\u6e32\u67d3\u52a8\u753b\u6216\u9875\u9762\u7684\u6bcf\u4e00\u5e27\u7684\u901f\u7387\u4e5f\u9700\u8981\u8ddf\u8bbe\u5907\u5c4f\u5e55\u7684\u5237\u65b0\u7387\u4fdd\u6301\u4e00\u81f4\u3002<br \/>\n\u5176\u4e2d\u6bcf\u4e2a\u5e27\u7684\u9884\u7b97\u65f6\u95f4\u4ec5\u6bd4 16 \u6beb\u79d2\u591a\u4e00\u70b9 (1 \u79d2\/ 60 = 16.66 \u6beb\u79d2)\u3002\u4f46\u5b9e\u9645\u4e0a\uff0c\u6d4f\u89c8\u5668\u6709\u6574\u7406\u5de5\u4f5c\u8981\u505a\uff0c\u56e0\u6b64\u60a8\u7684\u6240\u6709\u5de5\u4f5c\u9700\u8981\u5728 10 \u6beb\u79d2\u5185\u5b8c\u6210\u3002\u5982\u679c\u65e0\u6cd5\u7b26\u5408\u6b64\u9884\u7b97\uff0c\u5e27\u7387\u5c06\u4e0b\u964d\uff0c\u5e76\u4e14\u5185\u5bb9\u4f1a\u5728\u5c4f\u5e55\u4e0a\u6296\u52a8\u3002 \u6b64\u73b0\u8c61\u901a\u5e38\u79f0\u4e3a\u5361\u987f\uff0c\u4f1a\u5bf9\u7528\u6237\u4f53\u9a8c\u4ea7\u751f\u8d1f\u9762\u5f71\u54cd\u3002<\/p><\/blockquote>\n<p><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/QQ\u255c\u256a\u2550\u255d20200413202559.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2618\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/QQ\u255c\u256a\u2550\u255d20200413202559.png\" alt=\"QQ\u255c\u256a\u2550\u255d20200413202559\" width=\"778\" height=\"104\" \/><\/a><br \/>\n\u5047\u5982\u4f60\u7528 JavaScript \u4fee\u6539\u4e86 DOM\uff0c\u5e76\u89e6\u53d1\u6837\u5f0f\u4fee\u6539\uff0c\u7ecf\u5386\u91cd\u6392\u91cd\u7ed8\u6700\u540e\u753b\u5230\u5c4f\u5e55\u4e0a\u3002\u5982\u679c\u8fd9\u5176\u4e2d\u4efb\u610f\u4e00\u9879\u7684\u6267\u884c\u65f6\u95f4\u8fc7\u957f\uff0c\u90fd\u4f1a\u5bfc\u81f4\u6e32\u67d3\u8fd9\u4e00\u5e27\u7684\u65f6\u95f4\u8fc7\u957f\uff0c\u5e73\u5747\u5e27\u7387\u5c31\u4f1a\u4e0b\u964d\u3002\u5047\u8bbe\u8fd9\u4e00\u5e27\u82b1\u4e86 50 ms\uff0c\u90a3\u4e48\u6b64\u65f6\u7684\u5e27\u7387\u4e3a 1s \/ 50ms = 20fps\uff0c\u9875\u9762\u770b\u8d77\u6765\u5c31\u50cf\u5361\u987f\u4e86\u4e00\u6837\u3002<\/p>\n<p>\u5bf9\u4e8e\u4e00\u4e9b\u957f\u65f6\u95f4\u8fd0\u884c\u7684 JavaScript\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5b9a\u65f6\u5668\u8fdb\u884c\u5207\u5206\uff0c\u5ef6\u8fdf\u6267\u884c\u3002<\/p>\n<pre class=\"javascript hljs\"><code class=\"js\"><span class=\"hljs-keyword\">for<\/span> (<span class=\"hljs-keyword\">let<\/span> i = <span class=\"hljs-number\">0<\/span>, len = arry.length; i &lt; len; i++) {\r\n    process(arry[i])\r\n}<\/code><\/pre>\n<p>\u5047\u8bbe\u4e0a\u9762\u7684\u5faa\u73af\u7ed3\u6784\u7531\u4e8e process() \u590d\u6742\u5ea6\u8fc7\u9ad8\u6216\u6570\u7ec4\u5143\u7d20\u592a\u591a\uff0c\u751a\u81f3\u4e24\u8005\u90fd\u6709\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4e00\u4e0b\u5207\u5206\u3002<\/p>\n<pre class=\"javascript hljs\"><code class=\"js\"><span class=\"hljs-keyword\">const<\/span> todo = arry.concat()\r\nsetTimeout(<span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> {\r\n    process(todo.shift())\r\n    <span class=\"hljs-keyword\">if<\/span> (todo.length) {\r\n        setTimeout(<span class=\"hljs-built_in\">arguments<\/span>.callee, <span class=\"hljs-number\">25<\/span>)\r\n    } <span class=\"hljs-keyword\">else<\/span> {\r\n        callback(arry)\r\n    }\r\n}, <span class=\"hljs-number\">25<\/span>)<\/code><\/pre>\n<p>\u5982\u679c\u6709\u5174\u8da3\u4e86\u89e3\u66f4\u591a\uff0c\u53ef\u4ee5\u67e5\u770b\u4e00\u4e0b<a href=\"https:\/\/github.com\/woai3c\/recommended-books\/blob\/master\/%E5%89%8D%E7%AB%AF\/%E9%AB%98%E6%80%A7%E8%83%BDJavaScript.pdf\" target=\"_blank\" rel=\"nofollow noreferrer\">\u9ad8\u6027\u80fdJavaScript<\/a>\u7b2c 6 \u7ae0\u548c<a href=\"https:\/\/book.douban.com\/subject\/30170670\/\" target=\"_blank\" rel=\"nofollow noreferrer\">\u9ad8\u6548\u524d\u7aef\uff1aWeb\u9ad8\u6548\u7f16\u7a0b\u4e0e\u4f18\u5316\u5b9e\u8df5<\/a>\u7b2c 3 \u7ae0\u3002<\/p>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/developers.google.com\/web\/fundamentals\/performance\/rendering\" target=\"_blank\" rel=\"nofollow noreferrer\">\u6e32\u67d3\u6027\u80fd<\/a><\/li>\n<\/ul>\n<h4>17. \u4f7f\u7528 requestAnimationFrame \u6765\u5b9e\u73b0\u89c6\u89c9\u53d8\u5316<\/h4>\n<p>\u4ece\u7b2c 16 \u70b9\u6211\u4eec\u53ef\u4ee5\u77e5\u9053\uff0c\u5927\u591a\u6570\u8bbe\u5907\u5c4f\u5e55\u5237\u65b0\u7387\u4e3a 60 \u6b21\/\u79d2\uff0c\u4e5f\u5c31\u662f\u8bf4\u6bcf\u4e00\u5e27\u7684\u5e73\u5747\u65f6\u95f4\u4e3a 16.66 \u6beb\u79d2\u3002\u5728\u4f7f\u7528 JavaScript \u5b9e\u73b0\u52a8\u753b\u6548\u679c\u7684\u65f6\u5019\uff0c\u6700\u597d\u7684\u60c5\u51b5\u5c31\u662f\u6bcf\u6b21\u4ee3\u7801\u90fd\u662f\u5728\u5e27\u7684\u5f00\u5934\u5f00\u59cb\u6267\u884c\u3002\u800c\u4fdd\u8bc1 JavaScript \u5728\u5e27\u5f00\u59cb\u65f6\u8fd0\u884c\u7684\u552f\u4e00\u65b9\u5f0f\u662f\u4f7f\u7528\u00a0<code>requestAnimationFrame<\/code>\u3002<\/p>\n<pre class=\"javascript hljs\"><code class=\"js\"><span class=\"hljs-comment\">\/**\r\n * If run as a requestAnimationFrame callback, this\r\n * will be run at the start of the frame.\r\n *\/<\/span>\r\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">updateScreen<\/span>(<span class=\"hljs-params\">time<\/span>) <\/span>{\r\n  <span class=\"hljs-comment\">\/\/ Make visual updates here.<\/span>\r\n}\r\n\r\nrequestAnimationFrame(updateScreen);<\/code><\/pre>\n<p>\u5982\u679c\u91c7\u53d6\u00a0<code>setTimeout<\/code>\u00a0\u6216\u00a0<code>setInterval<\/code>\u00a0\u6765\u5b9e\u73b0\u52a8\u753b\u7684\u8bdd\uff0c\u56de\u8c03\u51fd\u6570\u5c06\u5728\u5e27\u4e2d\u7684\u67d0\u4e2a\u65f6\u70b9\u8fd0\u884c\uff0c\u53ef\u80fd\u521a\u597d\u5728\u672b\u5c3e\uff0c\u800c\u8fd9\u53ef\u80fd\u7ecf\u5e38\u4f1a\u4f7f\u6211\u4eec\u4e22\u5931\u5e27\uff0c\u5bfc\u81f4\u5361\u987f\u3002<br \/>\n<a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/QQ\u255c\u256a\u2550\u255d20200413202614.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2619\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/QQ\u255c\u256a\u2550\u255d20200413202614.png\" alt=\"QQ\u255c\u256a\u2550\u255d20200413202614\" width=\"776\" height=\"327\" \/><\/a><br \/>\n\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/developers.google.com\/web\/fundamentals\/performance\/rendering\/optimize-javascript-execution?hl=zh-cn\" target=\"_blank\" rel=\"nofollow noreferrer\">\u4f18\u5316 JavaScript \u6267\u884c<\/a><\/li>\n<\/ul>\n<h4>18. \u4f7f\u7528 Web Workers<\/h4>\n<p>Web Worker \u4f7f\u7528\u5176\u4ed6\u5de5\u4f5c\u7ebf\u7a0b\u4ece\u800c\u72ec\u7acb\u4e8e\u4e3b\u7ebf\u7a0b\u4e4b\u5916\uff0c\u5b83\u53ef\u4ee5\u6267\u884c\u4efb\u52a1\u800c\u4e0d\u5e72\u6270\u7528\u6237\u754c\u9762\u3002\u4e00\u4e2a worker \u53ef\u4ee5\u5c06\u6d88\u606f\u53d1\u9001\u5230\u521b\u5efa\u5b83\u7684 JavaScript \u4ee3\u7801, \u901a\u8fc7\u5c06\u6d88\u606f\u53d1\u9001\u5230\u8be5\u4ee3\u7801\u6307\u5b9a\u7684\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\uff08\u53cd\u4e4b\u4ea6\u7136\uff09\u3002<\/p>\n<p>Web Worker \u9002\u7528\u4e8e\u90a3\u4e9b\u5904\u7406\u7eaf\u6570\u636e\uff0c\u6216\u8005\u4e0e\u6d4f\u89c8\u5668 UI \u65e0\u5173\u7684\u957f\u65f6\u95f4\u8fd0\u884c\u811a\u672c\u3002<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 worker \u5f88\u7b80\u5355\uff0c\u6307\u5b9a\u4e00\u4e2a\u811a\u672c\u7684 URI \u6765\u6267\u884c worker \u7ebf\u7a0b\uff08main.js\uff09\uff1a<\/p>\n<pre class=\"javascript hljs\"><code class=\"js\"><span class=\"hljs-keyword\">var<\/span> myWorker = <span class=\"hljs-keyword\">new<\/span> Worker(<span class=\"hljs-string\">'worker.js'<\/span>);\r\n<span class=\"hljs-comment\">\/\/ \u4f60\u53ef\u4ee5\u901a\u8fc7postMessage() \u65b9\u6cd5\u548conmessage\u4e8b\u4ef6\u5411worker\u53d1\u9001\u6d88\u606f\u3002<\/span>\r\nfirst.onchange = <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span>() <\/span>{\r\n  myWorker.postMessage([first.value,second.value]);\r\n  <span class=\"hljs-built_in\">console<\/span>.log(<span class=\"hljs-string\">'Message posted to worker'<\/span>);\r\n}\r\n\r\nsecond.onchange = <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span>() <\/span>{\r\n  myWorker.postMessage([first.value,second.value]);\r\n  <span class=\"hljs-built_in\">console<\/span>.log(<span class=\"hljs-string\">'Message posted to worker'<\/span>);\r\n}<\/code><\/pre>\n<p>\u5728 worker \u4e2d\u63a5\u6536\u5230\u6d88\u606f\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5199\u4e00\u4e2a\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u4ee3\u7801\u4f5c\u4e3a\u54cd\u5e94\uff08worker.js\uff09\uff1a<\/p>\n<pre class=\"javascript hljs\"><code class=\"js\">onmessage = <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span>(<span class=\"hljs-params\">e<\/span>) <\/span>{\r\n  <span class=\"hljs-built_in\">console<\/span>.log(<span class=\"hljs-string\">'Message received from main script'<\/span>);\r\n  <span class=\"hljs-keyword\">var<\/span> workerResult = <span class=\"hljs-string\">'Result: '<\/span> + (e.data[<span class=\"hljs-number\">0<\/span>] * e.data[<span class=\"hljs-number\">1<\/span>]);\r\n  <span class=\"hljs-built_in\">console<\/span>.log(<span class=\"hljs-string\">'Posting message back to main script'<\/span>);\r\n  postMessage(workerResult);\r\n}<\/code><\/pre>\n<p>onmessage\u5904\u7406\u51fd\u6570\u5728\u63a5\u6536\u5230\u6d88\u606f\u540e\u9a6c\u4e0a\u6267\u884c\uff0c\u4ee3\u7801\u4e2d\u6d88\u606f\u672c\u8eab\u4f5c\u4e3a\u4e8b\u4ef6\u7684data\u5c5e\u6027\u8fdb\u884c\u4f7f\u7528\u3002\u8fd9\u91cc\u6211\u4eec\u7b80\u5355\u7684\u5bf9\u8fd92\u4e2a\u6570\u5b57\u4f5c\u4e58\u6cd5\u5904\u7406\u5e76\u518d\u6b21\u4f7f\u7528postMessage()\u65b9\u6cd5\uff0c\u5c06\u7ed3\u679c\u56de\u4f20\u7ed9\u4e3b\u7ebf\u7a0b\u3002<\/p>\n<p>\u56de\u5230\u4e3b\u7ebf\u7a0b\uff0c\u6211\u4eec\u518d\u6b21\u4f7f\u7528onmessage\u4ee5\u54cd\u5e94worker\u56de\u4f20\u7684\u6d88\u606f\uff1a<\/p>\n<pre class=\"javascript hljs\"><code class=\"js\">myWorker.onmessage = <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span>(<span class=\"hljs-params\">e<\/span>) <\/span>{\r\n  result.textContent = e.data;\r\n  <span class=\"hljs-built_in\">console<\/span>.log(<span class=\"hljs-string\">'Message received from worker'<\/span>);\r\n}<\/code><\/pre>\n<p>\u5728\u8fd9\u91cc\u6211\u4eec\u83b7\u53d6\u6d88\u606f\u4e8b\u4ef6\u7684data\uff0c\u5e76\u4e14\u5c06\u5b83\u8bbe\u7f6e\u4e3aresult\u7684textContent\uff0c\u6240\u4ee5\u7528\u6237\u53ef\u4ee5\u76f4\u63a5\u770b\u5230\u8fd0\u7b97\u7684\u7ed3\u679c\u3002<\/p>\n<p>\u4e0d\u8fc7\u5728worker\u5185\uff0c\u4e0d\u80fd\u76f4\u63a5\u64cd\u4f5cDOM\u8282\u70b9\uff0c\u4e5f\u4e0d\u80fd\u4f7f\u7528window\u5bf9\u8c61\u7684\u9ed8\u8ba4\u65b9\u6cd5\u548c\u5c5e\u6027\u3002\u7136\u800c\u4f60\u53ef\u4ee5\u4f7f\u7528\u5927\u91cfwindow\u5bf9\u8c61\u4e4b\u4e0b\u7684\u4e1c\u897f\uff0c\u5305\u62ecWebSockets\uff0cIndexedDB\u4ee5\u53caFireFox OS\u4e13\u7528\u7684Data Store API\u7b49\u6570\u636e\u5b58\u50a8\u673a\u5236\u3002<\/p>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/developer.mozilla.org\/zh-CN\/docs\/Web\/API\/Web_Workers_API\/Using_web_workers\" target=\"_blank\" rel=\"nofollow noreferrer\">Web Workers<\/a><\/li>\n<\/ul>\n<h4>19. \u4f7f\u7528\u4f4d\u64cd\u4f5c<\/h4>\n<p>JavaScript \u4e2d\u7684\u6570\u5b57\u90fd\u4f7f\u7528 IEEE-754 \u6807\u51c6\u4ee5 64 \u4f4d\u683c\u5f0f\u5b58\u50a8\u3002\u4f46\u662f\u5728\u4f4d\u64cd\u4f5c\u4e2d\uff0c\u6570\u5b57\u88ab\u8f6c\u6362\u4e3a\u6709\u7b26\u53f7\u7684 32 \u4f4d\u683c\u5f0f\u3002\u5373\u4f7f\u9700\u8981\u8f6c\u6362\uff0c\u4f4d\u64cd\u4f5c\u4e5f\u6bd4\u5176\u4ed6\u6570\u5b66\u8fd0\u7b97\u548c\u5e03\u5c14\u64cd\u4f5c\u5feb\u5f97\u591a\u3002<br \/>\n<strong>\u53d6\u6a21<\/strong><br \/>\n\u7531\u4e8e\u5076\u6570\u7684\u6700\u4f4e\u4f4d\u4e3a 0\uff0c\u5947\u6570\u4e3a 1\uff0c\u6240\u4ee5\u53d6\u6a21\u8fd0\u7b97\u53ef\u4ee5\u7528\u4f4d\u64cd\u4f5c\u6765\u4ee3\u66ff\u3002<\/p>\n<pre class=\"javascript hljs\"><code class=\"js\"><span class=\"hljs-keyword\">if<\/span> (value % <span class=\"hljs-number\">2<\/span>) {\r\n    <span class=\"hljs-comment\">\/\/ \u5947\u6570<\/span>\r\n} <span class=\"hljs-keyword\">else<\/span> {\r\n    <span class=\"hljs-comment\">\/\/ \u5076\u6570 <\/span>\r\n}\r\n<span class=\"hljs-comment\">\/\/ \u4f4d\u64cd\u4f5c<\/span>\r\n<span class=\"hljs-keyword\">if<\/span> (value &amp; <span class=\"hljs-number\">1<\/span>) {\r\n    <span class=\"hljs-comment\">\/\/ \u5947\u6570<\/span>\r\n} <span class=\"hljs-keyword\">else<\/span> {\r\n    <span class=\"hljs-comment\">\/\/ \u5076\u6570<\/span>\r\n}<\/code><\/pre>\n<p><strong>\u53d6\u53cd<\/strong><\/p>\n<pre class=\"javascript hljs\"><code class=\"js\">~~<span class=\"hljs-number\">10.12<\/span> <span class=\"hljs-comment\">\/\/ 10<\/span>\r\n~~<span class=\"hljs-number\">10<\/span> <span class=\"hljs-comment\">\/\/ 10<\/span>\r\n~~<span class=\"hljs-string\">'1.5'<\/span> <span class=\"hljs-comment\">\/\/ 1<\/span>\r\n~~<span class=\"hljs-literal\">undefined<\/span> <span class=\"hljs-comment\">\/\/ 0<\/span>\r\n~~<span class=\"hljs-literal\">null<\/span> <span class=\"hljs-comment\">\/\/ 0<\/span><\/code><\/pre>\n<p><strong>\u4f4d\u63a9\u7801<\/strong><\/p>\n<pre class=\"javascript hljs\"><code class=\"js\"><span class=\"hljs-keyword\">const<\/span> a = <span class=\"hljs-number\">1<\/span>\r\n<span class=\"hljs-keyword\">const<\/span> b = <span class=\"hljs-number\">2<\/span>\r\n<span class=\"hljs-keyword\">const<\/span> c = <span class=\"hljs-number\">4<\/span>\r\n<span class=\"hljs-keyword\">const<\/span> options = a | b | c<\/code><\/pre>\n<p>\u901a\u8fc7\u5b9a\u4e49\u8fd9\u4e9b\u9009\u9879\uff0c\u53ef\u4ee5\u7528\u6309\u4f4d\u4e0e\u64cd\u4f5c\u6765\u5224\u65ad a\/b\/c \u662f\u5426\u5728 options \u4e2d\u3002<\/p>\n<pre class=\"javascript hljs\"><code class=\"js\"><span class=\"hljs-comment\">\/\/ \u9009\u9879 b \u662f\u5426\u5728\u9009\u9879\u4e2d<\/span>\r\n<span class=\"hljs-keyword\">if<\/span> (b &amp; options) {\r\n    ...\r\n}<\/code><\/pre>\n<h4>20. \u4e0d\u8981\u8986\u76d6\u539f\u751f\u65b9\u6cd5<\/h4>\n<p>\u65e0\u8bba\u4f60\u7684 JavaScript \u4ee3\u7801\u5982\u4f55\u4f18\u5316\uff0c\u90fd\u6bd4\u4e0d\u4e0a\u539f\u751f\u65b9\u6cd5\u3002\u56e0\u4e3a\u539f\u751f\u65b9\u6cd5\u662f\u7528\u4f4e\u7ea7\u8bed\u8a00\u5199\u7684\uff08C\/C++\uff09\uff0c\u5e76\u4e14\u88ab\u7f16\u8bd1\u6210\u673a\u5668\u7801\uff0c\u6210\u4e3a\u6d4f\u89c8\u5668\u7684\u4e00\u90e8\u5206\u3002\u5f53\u539f\u751f\u65b9\u6cd5\u53ef\u7528\u65f6\uff0c\u5c3d\u91cf\u4f7f\u7528\u5b83\u4eec\uff0c\u7279\u522b\u662f\u6570\u5b66\u8fd0\u7b97\u548c DOM \u64cd\u4f5c\u3002<\/p>\n<h4>21. \u964d\u4f4e CSS \u9009\u62e9\u5668\u7684\u590d\u6742\u6027<\/h4>\n<p><strong>(1). \u6d4f\u89c8\u5668\u8bfb\u53d6\u9009\u62e9\u5668\uff0c\u9075\u5faa\u7684\u539f\u5219\u662f\u4ece\u9009\u62e9\u5668\u7684\u53f3\u8fb9\u5230\u5de6\u8fb9\u8bfb\u53d6\u3002<\/strong><\/p>\n<p>\u770b\u4e2a\u793a\u4f8b<\/p>\n<pre class=\"css hljs\"><code class=\"css\"><span class=\"hljs-selector-id\">#block<\/span> <span class=\"hljs-selector-class\">.text<\/span> <span class=\"hljs-selector-tag\">p<\/span> {\r\n    <span class=\"hljs-attribute\">color<\/span>: red;\r\n}<\/code><\/pre>\n<ol>\n<li>\u67e5\u627e\u6240\u6709 P \u5143\u7d20\u3002<\/li>\n<li>\u67e5\u627e\u7ed3\u679c 1 \u4e2d\u7684\u5143\u7d20\u662f\u5426\u6709\u7c7b\u540d\u4e3a text \u7684\u7236\u5143\u7d20<\/li>\n<li>\u67e5\u627e\u7ed3\u679c 2 \u4e2d\u7684\u5143\u7d20\u662f\u5426\u6709 id \u4e3a block \u7684\u7236\u5143\u7d20<\/li>\n<\/ol>\n<p><strong>(2). CSS \u9009\u62e9\u5668\u4f18\u5148\u7ea7<\/strong><\/p>\n<pre class=\"hljs\"><code>\u5185\u8054 &gt; ID\u9009\u62e9\u5668 &gt; \u7c7b\u9009\u62e9\u5668 &gt; \u6807\u7b7e\u9009\u62e9\u5668<\/code><\/pre>\n<p>\u6839\u636e\u4ee5\u4e0a\u4e24\u4e2a\u4fe1\u606f\u53ef\u4ee5\u5f97\u51fa\u7ed3\u8bba\u3002<\/p>\n<ol>\n<li>\u9009\u62e9\u5668\u8d8a\u77ed\u8d8a\u597d\u3002<\/li>\n<li>\u5c3d\u91cf\u4f7f\u7528\u9ad8\u4f18\u5148\u7ea7\u7684\u9009\u62e9\u5668\uff0c\u4f8b\u5982 ID \u548c\u7c7b\u9009\u62e9\u5668\u3002<\/li>\n<li>\u907f\u514d\u4f7f\u7528\u901a\u914d\u7b26 *\u3002<\/li>\n<\/ol>\n<p>\u6700\u540e\u8981\u8bf4\u4e00\u53e5\uff0c\u636e\u6211\u67e5\u627e\u7684\u8d44\u6599\u6240\u5f97\uff0cCSS \u9009\u62e9\u5668\u6ca1\u6709\u4f18\u5316\u7684\u5fc5\u8981\uff0c\u56e0\u4e3a\u6700\u6162\u548c\u6162\u5feb\u7684\u9009\u62e9\u5668\u6027\u80fd\u5dee\u522b\u975e\u5e38\u5c0f\u3002<\/p>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/ecss.io\/appendix1.html\" target=\"_blank\" rel=\"nofollow noreferrer\">CSS selector performance<\/a><\/li>\n<li><a href=\"https:\/\/www.sitepoint.com\/optimizing-css-id-selectors-and-other-myths\/\" target=\"_blank\" rel=\"nofollow noreferrer\">Optimizing CSS: ID Selectors and Other Myths<\/a><\/li>\n<\/ul>\n<h4>22. \u4f7f\u7528 flexbox \u800c\u4e0d\u662f\u8f83\u65e9\u7684\u5e03\u5c40\u6a21\u578b<\/h4>\n<p>\u5728\u65e9\u671f\u7684 CSS \u5e03\u5c40\u65b9\u5f0f\u4e2d\u6211\u4eec\u80fd\u5bf9\u5143\u7d20\u5b9e\u884c\u7edd\u5bf9\u5b9a\u4f4d\u3001\u76f8\u5bf9\u5b9a\u4f4d\u6216\u6d6e\u52a8\u5b9a\u4f4d\u3002\u800c\u73b0\u5728\uff0c\u6211\u4eec\u6709\u4e86\u65b0\u7684\u5e03\u5c40\u65b9\u5f0f\u00a0<a href=\"https:\/\/developer.mozilla.org\/zh-CN\/docs\/Web\/CSS\/CSS_Flexible_Box_Layout\/Basic_Concepts_of_Flexbox\" target=\"_blank\" rel=\"nofollow noreferrer\">flexbox<\/a>\uff0c\u5b83\u6bd4\u8d77\u65e9\u671f\u7684\u5e03\u5c40\u65b9\u5f0f\u6765\u8bf4\u6709\u4e2a\u4f18\u52bf\uff0c\u90a3\u5c31\u662f\u6027\u80fd\u6bd4\u8f83\u597d\u3002<\/p>\n<p>\u4e0b\u9762\u7684\u622a\u56fe\u663e\u793a\u4e86\u5728 1300 \u4e2a\u6846\u4e0a\u4f7f\u7528\u6d6e\u52a8\u7684\u5e03\u5c40\u5f00\u9500\uff1a<br \/>\n<a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/QQ\u255c\u256a\u2550\u255d20200413202635.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2620\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/QQ\u255c\u256a\u2550\u255d20200413202635.png\" alt=\"QQ\u255c\u256a\u2550\u255d20200413202635\" width=\"744\" height=\"491\" \/><\/a><br \/>\n\u7136\u540e\u6211\u4eec\u7528 flexbox \u6765\u91cd\u73b0\u8fd9\u4e2a\u4f8b\u5b50\uff1a<br \/>\n<a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/QQ\u255c\u256a\u2550\u255d20200413202655.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2621\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/QQ\u255c\u256a\u2550\u255d20200413202655.png\" alt=\"QQ\u255c\u256a\u2550\u255d20200413202655\" width=\"760\" height=\"492\" \/><\/a><br \/>\n\u73b0\u5728\uff0c\u5bf9\u4e8e\u76f8\u540c\u6570\u91cf\u7684\u5143\u7d20\u548c\u76f8\u540c\u7684\u89c6\u89c9\u5916\u89c2\uff0c\u5e03\u5c40\u7684\u65f6\u95f4\u8981\u5c11\u5f97\u591a\uff08\u672c\u4f8b\u4e2d\u4e3a\u5206\u522b 3.5 \u6beb\u79d2\u548c 14 \u6beb\u79d2\uff09\u3002<\/p>\n<p>\u4e0d\u8fc7 flexbox \u517c\u5bb9\u6027\u8fd8\u662f\u6709\u70b9\u95ee\u9898\uff0c\u4e0d\u662f\u6240\u6709\u6d4f\u89c8\u5668\u90fd\u652f\u6301\u5b83\uff0c\u6240\u4ee5\u8981\u8c28\u614e\u4f7f\u7528\u3002<\/p>\n<p>\u5404\u6d4f\u89c8\u5668\u517c\u5bb9\u6027\uff1a<\/p>\n<ul>\n<li>Chrome 29+<\/li>\n<li>Firefox 28+<\/li>\n<li>Internet Explorer 11<\/li>\n<li>Opera 17+<\/li>\n<li>Safari 6.1+ (prefixed with -webkit-)<\/li>\n<li>Android 4.4+<\/li>\n<li>iOS 7.1+ (prefixed with -webkit-)<\/li>\n<\/ul>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/developers.google.com\/web\/fundamentals\/performance\/rendering\/avoid-large-complex-layouts-and-layout-thrashing?hl=zh-cn\" target=\"_blank\" rel=\"nofollow noreferrer\">\u4f7f\u7528 flexbox \u800c\u4e0d\u662f\u8f83\u65e9\u7684\u5e03\u5c40\u6a21\u578b<\/a><\/li>\n<\/ul>\n<h4>23. \u4f7f\u7528 transform \u548c opacity \u5c5e\u6027\u66f4\u6539\u6765\u5b9e\u73b0\u52a8\u753b<\/h4>\n<p>\u5728 CSS \u4e2d\uff0ctransforms \u548c opacity \u8fd9\u4e24\u4e2a\u5c5e\u6027\u66f4\u6539\u4e0d\u4f1a\u89e6\u53d1\u91cd\u6392\u4e0e\u91cd\u7ed8\uff0c\u5b83\u4eec\u662f\u53ef\u4ee5\u7531\u5408\u6210\u5668\uff08composite\uff09\u5355\u72ec\u5904\u7406\u7684\u5c5e\u6027\u3002<br \/>\n<a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/QQ\u255c\u256a\u2550\u255d20200413202712.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2622\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/QQ\u255c\u256a\u2550\u255d20200413202712.png\" alt=\"QQ\u255c\u256a\u2550\u255d20200413202712\" width=\"814\" height=\"110\" \/><\/a><\/p>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/developers.google.com\/web\/fundamentals\/performance\/rendering\/stick-to-compositor-only-properties-and-manage-layer-count?hl=zh-cn\" target=\"_blank\" rel=\"nofollow noreferrer\">\u4f7f\u7528 transform \u548c opacity \u5c5e\u6027\u66f4\u6539\u6765\u5b9e\u73b0\u52a8\u753b<\/a><\/li>\n<\/ul>\n<h4>24. \u5408\u7406\u4f7f\u7528\u89c4\u5219\uff0c\u907f\u514d\u8fc7\u5ea6\u4f18\u5316<\/h4>\n<p>\u6027\u80fd\u4f18\u5316\u4e3b\u8981\u5206\u4e3a\u4e24\u7c7b\uff1a<\/p>\n<ol>\n<li>\u52a0\u8f7d\u65f6\u4f18\u5316<\/li>\n<li>\u8fd0\u884c\u65f6\u4f18\u5316<\/li>\n<\/ol>\n<p>\u4e0a\u8ff0 23 \u6761\u5efa\u8bae\u4e2d\uff0c\u5c5e\u4e8e\u52a0\u8f7d\u65f6\u4f18\u5316\u7684\u662f\u524d\u9762 10 \u6761\u5efa\u8bae\uff0c\u5c5e\u4e8e\u8fd0\u884c\u65f6\u4f18\u5316\u7684\u662f\u540e\u9762 13 \u6761\u5efa\u8bae\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u6ca1\u6709\u5fc5\u8981 23 \u6761\u6027\u80fd\u4f18\u5316\u89c4\u5219\u90fd\u7528\u4e0a\uff0c\u6839\u636e\u7f51\u7ad9\u7528\u6237\u7fa4\u4f53\u6765\u505a\u9488\u5bf9\u6027\u7684\u8c03\u6574\u662f\u6700\u597d\u7684\uff0c\u8282\u7701\u7cbe\u529b\uff0c\u8282\u7701\u65f6\u95f4\u3002<\/p>\n<p>\u5728\u89e3\u51b3\u95ee\u9898\u4e4b\u524d\uff0c\u5f97\u5148\u627e\u51fa\u95ee\u9898\uff0c\u5426\u5219\u65e0\u4ece\u4e0b\u624b\u3002\u6240\u4ee5\u5728\u505a\u6027\u80fd\u4f18\u5316\u4e4b\u524d\uff0c\u6700\u597d\u5148\u8c03\u67e5\u4e00\u4e0b\u7f51\u7ad9\u7684\u52a0\u8f7d\u6027\u80fd\u548c\u8fd0\u884c\u6027\u80fd\u3002<\/p>\n<p><strong>\u68c0\u67e5\u52a0\u8f7d\u6027\u80fd<\/strong><br \/>\n\u4e00\u4e2a\u7f51\u7ad9\u52a0\u8f7d\u6027\u80fd\u5982\u4f55\u4e3b\u8981\u770b\u767d\u5c4f\u65f6\u95f4\u548c\u9996\u5c4f\u65f6\u95f4\u3002<\/p>\n<ul>\n<li>\u767d\u5c4f\u65f6\u95f4\uff1a\u6307\u4ece\u8f93\u5165\u7f51\u5740\uff0c\u5230\u9875\u9762\u5f00\u59cb\u663e\u793a\u5185\u5bb9\u7684\u65f6\u95f4\u3002<\/li>\n<li>\u9996\u5c4f\u65f6\u95f4\uff1a\u6307\u4ece\u8f93\u5165\u7f51\u5740\uff0c\u5230\u9875\u9762\u5b8c\u5168\u6e32\u67d3\u7684\u65f6\u95f4\u3002<\/li>\n<\/ul>\n<p>\u5c06\u4ee5\u4e0b\u811a\u672c\u653e\u5728\u00a0<code>&lt;\/head&gt;<\/code>\u00a0\u524d\u9762\u5c31\u80fd\u83b7\u53d6\u767d\u5c4f\u65f6\u95f4\u3002<\/p>\n<pre class=\"xml hljs\"><code class=\"html\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script<\/span>&gt;<\/span><span class=\"javascript\">\r\n    <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-built_in\">Date<\/span>() - performance.timing.navigationStart\r\n<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">script<\/span>&gt;<\/span><\/code><\/pre>\n<p>\u9996\u5c4f\u65f6\u95f4\u6bd4\u8f83\u590d\u6742\uff0c\u5f97\u8003\u8651\u6709\u56fe\u7247\u548c\u6ca1\u6709\u56fe\u7247\u7684\u60c5\u51b5\u3002<\/p>\n<p>\u5982\u679c\u6ca1\u6709\u56fe\u7247\uff0c\u5219\u5728\u00a0<code>window.onload<\/code>\u00a0\u4e8b\u4ef6\u91cc\u6267\u884c\u00a0<code>new Date() - performance.timing.navigationStart<\/code>\u00a0\u5373\u53ef\u83b7\u53d6\u9996\u5c4f\u65f6\u95f4\u3002<\/p>\n<p>\u5982\u679c\u6709\u56fe\u7247\uff0c\u5219\u8981\u5728\u6700\u540e\u4e00\u4e2a\u5728\u9996\u5c4f\u6e32\u67d3\u7684\u56fe\u7247\u7684\u00a0<code>onload<\/code>\u00a0\u4e8b\u4ef6\u91cc\u6267\u884c\u00a0<code>new Date() - performance.timing.navigationStart<\/code>\u00a0\u83b7\u53d6\u9996\u5c4f\u65f6\u95f4\uff0c\u5b9e\u65bd\u8d77\u6765\u6bd4\u8f83\u590d\u6742\uff0c\u5728\u8fd9\u91cc\u9650\u4e8e\u7bc7\u5e45\u5c31\u4e0d\u8bf4\u4e86\u3002<\/p>\n<p><strong>\u68c0\u67e5\u8fd0\u884c\u6027\u80fd<\/strong><\/p>\n<p>\u914d\u5408 chrome \u7684\u5f00\u53d1\u8005\u5de5\u5177\uff0c\u6211\u4eec\u53ef\u4ee5\u67e5\u770b\u7f51\u7ad9\u5728\u8fd0\u884c\u65f6\u7684\u6027\u80fd\u3002<\/p>\n<p>\u6253\u5f00\u7f51\u7ad9\uff0c\u6309 F12 \u9009\u62e9 performance\uff0c\u70b9\u51fb\u5de6\u4e0a\u89d2\u7684\u7070\u8272\u5706\u70b9\uff0c\u53d8\u6210\u7ea2\u8272\u5c31\u4ee3\u8868\u5f00\u59cb\u8bb0\u5f55\u4e86\u3002\u8fd9\u65f6\u53ef\u4ee5\u6a21\u4eff\u7528\u6237\u4f7f\u7528\u7f51\u7ad9\uff0c\u5728\u4f7f\u7528\u5b8c\u6bd5\u540e\uff0c\u70b9\u51fb stop\uff0c\u7136\u540e\u4f60\u5c31\u80fd\u770b\u5230\u7f51\u7ad9\u8fd0\u884c\u671f\u95f4\u7684\u6027\u80fd\u62a5\u544a\u3002\u5982\u679c\u6709\u7ea2\u8272\u7684\u5757\uff0c\u4ee3\u8868\u6709\u6389\u5e27\u7684\u60c5\u51b5\uff1b\u5982\u679c\u662f\u7eff\u8272\uff0c\u5219\u4ee3\u8868 FPS \u5f88\u597d\u3002performance \u7684\u5177\u4f53\u4f7f\u7528\u65b9\u6cd5\u8bf7\u7528\u641c\u7d22\u5f15\u64ce\u641c\u7d22\u4e00\u4e0b\uff0c\u6bd5\u7adf\u7bc7\u5e45\u6709\u9650\u3002<\/p>\n<p>\u901a\u8fc7\u68c0\u67e5\u52a0\u8f7d\u548c\u8fd0\u884c\u6027\u80fd\uff0c\u76f8\u4fe1\u4f60\u5bf9\u7f51\u7ad9\u6027\u80fd\u5df2\u7ecf\u6709\u4e86\u5927\u6982\u4e86\u89e3\u3002\u6240\u4ee5\u8fd9\u65f6\u5019\u8981\u505a\u7684\u4e8b\u60c5\uff0c\u5c31\u662f\u4f7f\u7528\u4e0a\u8ff0 23 \u6761\u5efa\u8bae\u5c3d\u60c5\u5730\u53bb\u4f18\u5316\u4f60\u7684\u7f51\u7ad9\uff0c\u52a0\u6cb9\uff01<\/p>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/developer.mozilla.org\/zh-CN\/docs\/Web\/API\/PerformanceTiming\/navigationStart\" target=\"_blank\" rel=\"nofollow noreferrer\">performance.timing.navigationStart<\/a><\/li>\n<\/ul>\n<h2 id=\"item-1\">\u5176\u4ed6\u53c2\u8003\u8d44\u6599<\/h2>\n<ul>\n<li><a href=\"https:\/\/developers.google.com\/web\/fundamentals\/performance\/why-performance-matters?hl=zh-cn\" target=\"_blank\" rel=\"nofollow noreferrer\">\u6027\u80fd\u4e3a\u4f55\u81f3\u5173\u91cd\u8981<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/woai3c\/recommended-books\/blob\/master\/%E5%89%8D%E7%AB%AF\/%E9%AB%98%E6%80%A7%E8%83%BD%E7%BD%91%E7%AB%99%E5%BB%BA%E8%AE%BE%E6%8C%87%E5%8D%97.pdf\" target=\"_blank\" rel=\"nofollow noreferrer\">\u9ad8\u6027\u80fd\u7f51\u7ad9\u5efa\u8bbe\u6307\u5357<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/woai3c\/recommended-books\/blob\/master\/%E5%89%8D%E7%AB%AF\/Web%E6%80%A7%E8%83%BD%E6%9D%83%E5%A8%81%E6%8C%87%E5%8D%97.pdf\" target=\"_blank\" rel=\"nofollow noreferrer\">Web\u6027\u80fd\u6743\u5a01\u6307\u5357<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/woai3c\/recommended-books\/blob\/master\/%E5%89%8D%E7%AB%AF\/%E9%AB%98%E6%80%A7%E8%83%BDJavaScript.pdf\" target=\"_blank\" rel=\"nofollow noreferrer\">\u9ad8\u6027\u80fdJavaScript<\/a><\/li>\n<li><a href=\"https:\/\/book.douban.com\/subject\/30170670\/\" target=\"_blank\" rel=\"nofollow noreferrer\">\u9ad8\u6548\u524d\u7aef\uff1aWeb\u9ad8\u6548\u7f16\u7a0b\u4e0e\u4f18\u5316\u5b9e\u8df5<\/a><\/li>\n<\/ul>\n<p>\u539f\u6587\u51fa\u5904:<a href=\"https:\/\/segmentfault.com\/a\/1190000022205291\">https:\/\/segmentfault.com\/a\/1190000022205291<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6027\u80fd\u4f18\u5316\u662f\u628a\u53cc\u5203\u5251\uff0c\u6709\u597d\u7684\u4e00\u9762\u4e5f\u6709\u574f\u7684\u4e00\u9762\u3002\u597d\u7684\u4e00\u9762\u5c31\u662f\u80fd\u63d0\u5347\u7f51\u7ad9\u6027\u80fd\uff0c\u574f\u7684\u4e00\u9762\u5c31\u662f\u914d\u7f6e\u9ebb\u70e6\uff0c\u6216\u8005\u8981\u9075\u5b88\u7684\u89c4\u5219 [&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\/2612"}],"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=2612"}],"version-history":[{"count":4,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2612\/revisions"}],"predecessor-version":[{"id":2702,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2612\/revisions\/2702"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2612"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2612"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2612"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}