{"id":2645,"date":"2020-04-14T21:05:34","date_gmt":"2020-04-14T13:05:34","guid":{"rendered":"http:\/\/www.yuguoxy.com\/geekhome\/?p=2645"},"modified":"2026-08-18T12:35:28","modified_gmt":"2026-08-18T04:35:28","slug":"%e7%bb%8f%e5%85%b8%e9%9d%a2%e8%af%95%e9%a2%98%ef%bc%9a%e4%bb%80%e4%b9%88%e6%98%af%e5%9b%9e%e6%b5%81%e5%92%8c%e9%87%8d%e7%bb%98%ef%bc%9f%e5%a6%82%e4%bd%95%e4%bc%98%e5%8c%96%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=2645","title":{"rendered":"\u7ecf\u5178\u9762\u8bd5\u9898\uff1a\u4ec0\u4e48\u662f\u56de\u6d41\u548c\u91cd\u7ed8\uff1f\u5982\u4f55\u4f18\u5316\uff1f"},"content":{"rendered":"<section id=\"wenyan\" style=\"font-family: system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', Roboto, sans-serif; line-height: 1.75; font-size: 16px; color: #000000; caret-color: #000000;\" data-provider=\"WenYan\">\n<p style=\"margin: 1em 0px;\">\u6d4f\u89c8\u5668\u6e32\u67d3\u4e00\u9875\u6709\u4e24\u6761\u5de5\u4f5c\uff1a\u8dd1 JS\u3001\u7b97 CSS\u3002\u5b83\u4eec\u662f<strong style=\"color: #4870ac;\">\u4e92\u65a5<\/strong>\u7684\u3002\u9762\u8bd5\u91cc\u300c\u56de\u6d41 \/ \u91cd\u7ed8\u300d\u95ee\u7684\u5c31\u662f\uff1a\u6539\u6837\u5f0f\u65f6\uff0c\u6d4f\u89c8\u5668\u8981\u4e0d\u8981\u91cd\u7b97\u51e0\u4f55\uff0c\u8981\u4e0d\u8981\u91cd\u753b\u50cf\u7d20\u3002<\/p>\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u56de\u6d41\uff08reflow\uff09<\/strong>\uff1arender tree \u4e00\u90e8\u5206\u6216\u5168\u90e8\u56e0\u4e3a\u5bbd\u9ad8\u3001\u5e03\u5c40\u3001\u663e\u793a\u9690\u85cf\u3001\u6216\u5185\u90e8\u6587\u5b57\u7ed3\u6784\u53d8\u4e86\uff0c\u9700\u8981\u91cd\u65b0\u6784\u5efa\u9875\u9762\u3002<strong style=\"color: #4870ac;\">\u91cd\u7ed8\uff08repaint\uff09<\/strong>\uff1a\u5bbd\u9ad8\u3001\u5e03\u5c40\u3001\u663e\u9690\u6ca1\u53d8\uff0c\u53ea\u6539\u5916\u89c2\uff08\u989c\u8272\u3001\u9634\u5f71\u7b49\uff09\u3002\u7ed3\u8bba\uff1a\u56de\u6d41\u5fc5\u5b9a\u89e6\u53d1\u91cd\u7ed8\uff0c\u91cd\u7ed8\u4e0d\u4e00\u5b9a\u89e6\u53d1\u56de\u6d41\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u907f\u514d\u56de\u6d41\u7684\u4e24\u6761\u5927\u65b9\u5411\uff1a\u5c11\u7528\u4f1a\u89e6\u53d1\u5e03\u5c40\u7684\u5c5e\u6027\uff1b\u628a\u53d8\u5316\u5173\u8fdb\u72ec\u7acb\u56fe\u5c42\uff0c\u9650\u5236\u8ba1\u7b97\u8303\u56f4\u3002<\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e00\u3001\u56fe\u5c42\u662f\u600e\u4e48\u5212\u5206\u7684<\/h2>\n<p style=\"margin: 1em 0px;\">DOM \u52a0\u8f7d\u5b8c\u540e\uff0c\u6d4f\u89c8\u5668\u4f1a\u6309\u4e00\u4e9b\u7279\u6b8a CSS\uff08\u4f8b\u5982 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">position: absolute | fixed<\/code>\uff09\u628a\u9875\u9762\u5212\u6210\u4e00\u4e2a\u4e2a\u56fe\u5c42\u3002\u5143\u7d20\u5728\u81ea\u5df1\u56fe\u5c42\u91cc\u53d8\u5316\u65f6\uff0c\u56de\u6d41\u548c\u91cd\u7ed8\u5c3d\u91cf\u53ea\u53d1\u751f\u5728\u56fe\u5c42\u5185\uff0c\u51cf\u5c11\u6574\u9875\u8ba1\u7b97\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u56fe\u5c42\u5185\u90e8\u5927\u81f4\u4f1a\uff1a\u5bf9\u8282\u70b9\u505a\u56de\u6d41\u548c\u518d\u5e03\u5c40\u3001\u7b97\u51fa\u6837\u5f0f\uff1b\u751f\u6210\u56fe\u5f62\u548c\u4f4d\u7f6e\uff1b\u628a\u6bcf\u4e2a\u8282\u70b9\u753b\u8fdb\u56fe\u5c42\u4f4d\u56fe\uff1b\u628a\u56fe\u5c42\u5f53\u7eb9\u7406\u9001\u5230 <a href=\"http:\/\/web.jobbole.com\/91031\/\" target=\"_blank\" title=\"\u4ec0\u4e48\u662f\u524d\u7aefGPU\u52a0\u901f\uff1f\">GPU<\/a>\uff1b\u518d\u628a\u6240\u6709\u56fe\u5c42\u5408\u5e76\u663e\u793a\u3002\u6ee5\u7528\u56fe\u5c42\u4f1a\u8ba9\u5408\u6210\u8fc7\u591a\uff0c\u9875\u9762\u53cd\u800c\u5361\u3002\u56fe\u5c42\u8be5\u7ed9\u300c\u7ecf\u5e38\u6539\u4f4d\u7f6e \/ \u5e03\u5c40\u300d\u7684\u5143\u7d20\uff0c\u6bd4\u5982\u8f6e\u64ad\u3002<\/p>\n<table style=\"display: table; text-align: left; overflow: auto; border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; overflow-wrap: break-word; word-break: break-all;\" width=\"800\">\n<thead>\n<tr>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u6982\u5ff5<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u89e6\u53d1\u6761\u4ef6<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u548c\u5bf9\u65b9\u7684\u5173\u7cfb<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u56de\u6d41 reflow<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u6539\u5bbd\u9ad8\u3001\u5e03\u5c40\u3001\u663e\u9690\u3001\u6587\u5b57\u7ed3\u6784<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u4e00\u5b9a\u4f34\u968f\u91cd\u7ed8<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u91cd\u7ed8 repaint<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u53ea\u6539\u5916\u89c2\uff0c\u51e0\u4f55\u4e0d\u53d8<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u4e0d\u4e00\u5b9a\u56de\u6d41<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u72ec\u7acb\u56fe\u5c42<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">absolute\/fixed\u3001\u90e8\u5206 3D transform \u7b49<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u628a\u8ba1\u7b97\u5173\u8fdb\u5c40\u90e8\uff0c\u4f46\u5408\u6210\u6709\u6210\u672c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e8c\u3001\u4e5d\u6761\u53ef\u66ff\u6362\u5199\u6cd5<\/h2>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u7528 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">transform<\/code> \u4ee3\u66ff top \/ left \/ margin-top \/ margin-left \u8fd9\u7c7b\u4f4d\u79fb\u3002<\/section>\n<\/li>\n<li>\n<section>\u7528 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">opacity<\/code> \u4ee3\u66ff visibility \u65f6\uff0c\u8981\u540c\u65f6\u6709 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">translate3d<\/code> \u6216 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">translateZ<\/code> \u624d\u80fd\u771f\u6b63\u907f\u5f00\u56de\u6d41\u3002\u5b9e\u9a8c\uff1a\u4e0d\u52a0 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">transform: translateZ(0)<\/code> \u7684 opacity \u4ecd\u4f1a\u56de\u6d41\uff1b\u5355\u7528 visibility \u5f80\u5f80\u53ea\u91cd\u7ed8\uff1bopacity + translateZ\/3d \u540e\u53ef\u4ee5\u65e2\u4e0d\u56de\u6d41\u4e5f\u4e0d\u91cd\u7ed8\u3002<\/section>\n<\/li>\n<li>\n<section>\u4e0d\u8981\u7528 JS \u7ed9 DOM \u8bbe\u591a\u6761\u6837\u5f0f\uff0c\u6539\u6210\u5207\u4e00\u4e2a className\u3002<\/section>\n<\/li>\n<li>\n<section>\u82e5\u5fc5\u987b\u7528 JS \u8bbe\u591a\u6761\u6837\u5f0f\uff0c\u5148\u9690\u85cf\u518d\u6539\uff0c\u6539\u5b8c\u518d\u663e\u793a\u3002<\/section>\n<\/li>\n<li>\n<section>\u4e0d\u8981\u5728\u5faa\u73af\u91cc\u8bfb <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">offsetWidth \/ offsetHeight \/ clientWidth \/ clientHeight<\/code>\u3002\u6d4f\u89c8\u5668\u6709\u56de\u6d41\u7f13\u51b2\u6808\uff0c\u5199\u6837\u5f0f\u4f1a\u6512\u4e00\u6279\u518d\u5237\uff1b\u53cd\u590d\u8bfb\u51e0\u4f55\u4f1a\u5f3a\u8feb\u7acb\u523b\u5237\u65b0\u6808\u3002\u628a\u503c\u7f13\u5b58\u5728\u5faa\u73af\u5916\u3002<\/section>\n<\/li>\n<li>\n<section>\u4e0d\u8981\u7528 table \u5e03\u5c40\uff1a\u4e00\u884c\u751a\u81f3\u4e00\u4e2a\u5355\u5143\u683c\u66f4\u65b0\u90fd\u53ef\u80fd\u8ba9\u6574\u8868\u91cd\u5e03\u5c40\u3002<\/section>\n<\/li>\n<li>\n<section>\u52a8\u753b\u901f\u5ea6\u6309\u4e1a\u52a1\u9700\u8981\uff0c\u4e0d\u5fc5\u76f2\u76ee\u6c42\u5feb\u3002<\/section>\n<\/li>\n<li>\n<section>\u9891\u7e41\u53d8\u5316\u7684\u5143\u7d20\u52a0 transform\uff1b\u89c6\u9891\u7528 video \u6807\u7b7e\u3002<\/section>\n<\/li>\n<li>\n<section>\u5fc5\u8981\u65f6\u5f00 GPU \u52a0\u901f\uff0c\u4f46\u4e0d\u80fd\u6ee5\u7528\u3002\u5f00\u52a0\u901f\u65f6\u6700\u597d\u7ed9\u5f53\u524d\u52a8\u753b\u5143\u7d20\u4e00\u4e2a\u66f4\u9ad8\u7684 z-index\uff0c\u4eba\u4e3a\u5e72\u6270\u590d\u5408\u5c42\u6392\u5e8f\uff0c\u51cf\u5c11 Chrome \u521b\u5efa\u591a\u4f59\u590d\u5408\u5c42\u3002<\/section>\n<\/li>\n<\/ul>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e09\u3001\u4ec0\u4e48\u662f 16ms \u4f18\u5316<\/h2>\n<p style=\"margin: 1em 0px;\">\u591a\u6570\u8bbe\u5907\u5237\u65b0\u7387 60 \u6b21\/\u79d2\uff081000\/60 \u2248 16.6ms\uff09\u3002\u6bcf\u4e00\u5e27\u8981\u5728\u7ea6 16ms \u5185\u753b\u5b8c\uff0c\u8d85\u65f6\u5c31\u4f1a\u5361\u3002\u6d4f\u89c8\u5668\u4e00\u5e27\u91cc\u5927\u81f4\u6309\u4e0b\u9762\u987a\u5e8f\u5e72\u6d3b\uff0c\u5c11\u505a Layout \/ Paint\uff0c\u52a8\u753b\u624d\u987a\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section><strong style=\"color: #4870ac;\">JavaScript<\/strong>\uff1a\u52a8\u753b\u3001DOM \u64cd\u4f5c\u3002<\/section>\n<\/li>\n<li>\n<section><strong style=\"color: #4870ac;\">Style<\/strong>\uff1a\u7b97\u51fa\u6bcf\u4e2a DOM \u8be5\u5957\u54ea\u4e9b CSS\u3002<\/section>\n<\/li>\n<li>\n<section><strong style=\"color: #4870ac;\">Layout<\/strong>\uff1a\u7b97\u5927\u5c0f\u548c\u4f4d\u7f6e\u3002\u7f51\u9875\u5e03\u5c40\u662f\u76f8\u5bf9\u7684\uff0c\u4e00\u4e2a\u5143\u7d20\u52a8\u4e86\u4f1a\u8fde\u5e26\u5176\u5b83\uff0c\u8fd9\u4e2a\u8fc7\u7a0b\u53eb reflow\u3002<\/section>\n<\/li>\n<li>\n<section><strong style=\"color: #4870ac;\">Paint<\/strong>\uff1a\u5728\u591a\u5c42\u4e0a\u753b\u6587\u5b57\u3001\u989c\u8272\u3001\u56fe\u3001\u8fb9\u6846\u3001\u9634\u5f71\u3002<\/section>\n<\/li>\n<li>\n<section><strong style=\"color: #4870ac;\">Composite<\/strong>\uff1a\u6309\u987a\u5e8f\u5408\u5e76\u56fe\u5c42\uff0c\u663e\u793a\u5230\u5c4f\u5e55\u3002<\/section>\n<\/li>\n<\/ul>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\">\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u4e00\u53e5\u8bdd\u603b\u7ed3\uff1a\u56de\u6d41\u6539\u51e0\u4f55\u3001\u91cd\u7ed8\u6539\u5916\u89c2\uff1b\u7528 transform\/opacity+\u56fe\u5c42\u4ee3\u66ff top\/visibility\uff0c\u907f\u514d\u5faa\u73af\u8bfb\u5e03\u5c40\u3001\u907f\u514d table \u548c\u9010\u6761\u6539 style\uff0c\u628a\u4e00\u5e27\u5de5\u4f5c\u538b\u8fdb\u7ea6 16ms\u3002<\/strong><\/p>\n<\/blockquote>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u6d4f\u89c8\u5668\u6e32\u67d3\u4e00\u9875\u6709\u4e24\u6761\u5de5\u4f5c\uff1a\u8dd1 JS\u3001\u7b97 CSS\u3002\u5b83\u4eec\u662f\u4e92\u65a5\u7684\u3002\u9762\u8bd5\u91cc\u300c\u56de\u6d41 \/ \u91cd\u7ed8\u300d\u95ee\u7684\u5c31\u662f\uff1a\u6539\u6837\u5f0f\u65f6\uff0c\u6d4f\u89c8 [&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":[209,140],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2645"}],"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=2645"}],"version-history":[{"count":3,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2645\/revisions"}],"predecessor-version":[{"id":2648,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2645\/revisions\/2648"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}