{"id":4923,"date":"2025-08-02T23:32:15","date_gmt":"2025-08-02T15:32:15","guid":{"rendered":"https:\/\/blog.odjbinail.cn\/?p=4923"},"modified":"2025-08-22T16:00:01","modified_gmt":"2025-08-22T08:00:01","slug":"web%e5%89%8d%e7%ab%af%e6%80%a7%e8%83%bd%e4%bc%98%e5%8c%96","status":"publish","type":"post","link":"https:\/\/blog.odjbinail.cn\/?p=4923","title":{"rendered":"Web\u524d\u7aef\u6027\u80fd\u4f18\u5316\uff08\u4e8c\uff09"},"content":{"rendered":"<h1>\u8d44\u6e90\u5408\u5e76\u4e0e\u538b\u7f29<\/h1>\n<ul>\n<li>\u7406\u89e3<strong>\u51cf\u5c11 http \u8bf7\u6c42\u6570\u91cf<\/strong>\u548c<strong>\u51cf\u5c11\u8bf7\u6c42\u8d44\u6e90\u5927\u5c0f<\/strong>\u4e24\u4e2a\u4f18\u5316\u8981\u70b9<\/li>\n<li>\u638c\u63e1\u538b\u7f29\u4e8e\u5408\u5e76\u7684\u539f\u7406<\/li>\n<li>\u638c\u63e1\u901a\u8fc7\u5728\u7ebf\u7f51\u7ad9\u548c fis3 \u4e24\u79cd\u5b9e\u73b0\u538b\u7f29\u4e0e\u5408\u5e76\u7684\u65b9\u6cd5<\/li>\n<\/ul>\n<h2>http \u6e05\u6c42\u7684\u8fc7\u7a0b\u53ca\u6f5c\u5728\u7684\u6027\u80fd\u4f18\u5316\u70b9<\/h2>\n<p><img data-original=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2025\/01\/2025011818080668.png\"  alt=\"\" \/><\/p>\n<noscript><img decoding=\"async\" src=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2025\/01\/2025011818080668.png\" alt=\"\" \/><\/p><\/noscript>\n<p><strong>\u6df1\u5165\u7406\u89e3 http \u8bf7\u6c42\u7684\u8fc7\u7a0b \u662f\u524d\u7aef\u6027\u80fd\u4f18\u5316\u7684\u6838\u5fc3<\/strong><\/p>\n<ul>\n<li>dns \u662f\u5426\u53ef\u4ee5\u901a\u8fc7\u7f13\u5b58\u51cf\u5c11 dns \u67e5\u8be2\u65f6\u95f4 ?<\/li>\n<li>\u7f51\u7edc\u8bf7\u6c42\u7684\u8fc7\u7a0b\u8d70\u6700\u8fd1\u7684\u7f51\u7edc\u73af\u5883 ?<\/li>\n<li>\u76f8\u540c\u7684\u9759\u6001\u8d44\u6e90\u662f\u5426\u53ef\u4ee5\u7f13\u5b58 ?<\/li>\n<li>\u80fd\u5426\u51cf\u5c11\u8bf7\u6c42 http \u8bf7\u6c42\u5927\u5c0f ?<\/li>\n<li>\u51cf\u5c11 http \u8bf7\u6c42<\/li>\n<li>\u670d\u52a1\u7aef\u6e32\u67d3<\/li>\n<\/ul>\n<h2>html \u538b\u7f29<\/h2>\n<p>HTML \u4ee3\u7801\u538b\u7f29\u5c31\u662f\u538b\u7f29\u8fd9\u4e9b\u5728\u6587\u672c\u6587\u4ef6\u4e2d\u6709\u610f\u4e49\uff0c\u4f46\u662f\u5728 HTML \u4e2d<strong>\u4e0d\u663e\u793a<\/strong>\u7684\u5b57\u7b26\uff0c\u5305\u62ec<strong>\u7a7a\u683c\uff0c\u5236\u8868\u7b26\uff0c\u6362\u884c\u7b26<\/strong>\u7b49\uff0c\u8fd8\u6709\u4e00\u4e9b\u5176\u4ed6\u610f\u4e49\u7684\u5b57\u7b26\uff0c\u5982<strong> HTML \u6ce8\u91ca<\/strong> \u4e5f\u53ef\u4ee5\u88ab\u538b\u7f29\u3002<\/p>\n<ul>\n<li>\u4f7f\u7528\u5728\u7ebf\u7f51\u7ad9\u8fdb\u884c\u538b\u7f29<\/li>\n<li>nodejs \u63d0\u4f9b\u4e86 html-minifier \u5de5\u5177\u7b49 npm \u5de5\u5177<\/li>\n<li>\u540e\u7aef\u6a21\u677f\u5f15\u64ce\u6e32\u67d3\u538b\u7f29<\/li>\n<\/ul>\n<h3>HTML \u4f18\u5316<\/h3>\n<ul>\n<li>\u51cf\u5c11 iframes \u4f7f\u7528<\/li>\n<li>\u538b\u7f29\u7a7a\u767d\u7b26, \u7a7a\u884c<\/li>\n<li>\u907f\u514d\u8282\u70b9\u6df1\u5c42\u7ea7\u5d4c\u5957 div \u76d2\u5b50<\/li>\n<li>\u907f\u514d table \u5e03\u5c40<\/li>\n<li>\u5220\u9664\u6ce8\u91ca<\/li>\n<li>css&amp;Javascript \u5c3d\u91cf\u5916\u94fe<\/li>\n<li>\u5220\u9664\u5143\u7d20\u9ed8\u8ba4\u5c5e\u6027<\/li>\n<li>\u5355\u95ed\u5408\u6807\u7b7e li img \u4e0d\u7528\u95ed\u5408?<\/li>\n<\/ul>\n<h2>CSS \u538b\u7f29<\/h2>\n<ul>\n<li>\u4f7f\u7528\u5728\u7ebf\u7f51\u7ad9\u8fdb\u884c\u538b\u7f29<\/li>\n<li>html-minifier \u5de5\u5177\u5bf9 html \u4e2d\u7684 css \u8fdb\u884c\u538b\u7f29<\/li>\n<li>\u4f7f\u7528 clean-css \u5bf9 css \u8fdb\u884c\u538b\u7f29<\/li>\n<\/ul>\n<h3>CSS \u5bf9\u6027\u80fd\u7684\u5f71\u54cd<\/h3>\n<p>nth-child<\/p>\n<h4>css \u4f18\u5316<\/h4>\n<ul>\n<li>\u964d\u4f4e CSS \u5bf9\u6e32\u67d3\u7684\u963b\u585e, \u5148\u52a0\u8f7d\u9996\u5c4f\u8d44\u6e90<\/li>\n<li>\u5229\u7528 GPU \u8fdb\u884c\u5b8c\u6210\u52a8\u753b<\/li>\n<li>\u4f7f\u7528 li{contain: layout}?\u8fd8\u6709?<\/li>\n<li>\u4f7f\u7528 font-display \u5c5e\u6027<\/li>\n<\/ul>\n<p><img data-original=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2024\/01\/2024010516402962.png\"  alt=\"\" \/><\/p>\n<noscript><img decoding=\"async\" src=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2024\/01\/2024010516402962.png\" alt=\"\" \/><\/p><\/noscript>\n<h2>Js \u538b\u7f29\u4e0e\u6df7\u4e71<\/h2>\n<ul>\n<li>\u65e0\u6548\u5b57\u7b26\u7684\u5220\u9664<\/li>\n<li>\u5254\u9664\u6ce8\u91ca<\/li>\n<li>\u4ee3\u7801\u8bed\u4e49\u7684\u7f29\u51cf\u548c\u4f18\u5316<\/li>\n<li>\u4ee3\u7801\u4fdd\u62a4<\/li>\n<\/ul>\n<p>\u5982\u4f55\u64cd\u4f5c:<\/p>\n<ul>\n<li>\u4f7f\u7528\u5728\u7ebf\u7f51\u7ad9\u8fdb\u884c\u538b\u7f29<\/li>\n<li>html-minifier \u5de5\u5177\u5bf9 html \u4e2d\u7684 js \u8fdb\u884c\u538b\u7f29<\/li>\n<li>\u4f7f\u7528 uglifyjs2 \u5bf9 js \u8fdb\u884c\u538b\u7f29<\/li>\n<li>\u4f7f\u7528 WebPack \u5bf9 JS \u5728\u6784\u5efa\u65f6\u538b\u7f29<\/li>\n<\/ul>\n<h2>\u6587\u4ef6\u5408\u5e76<\/h2>\n<p>\u5b58\u5728\u7684\u95ee\u9898:<\/p>\n<ul>\n<li>\u9996\u5c4f\u6e32\u67d3\u95ee\u9898<\/li>\n<li>\u7f13\u5b58\u5931\u6548\u95ee\u9898<\/li>\n<\/ul>\n<p>\u5efa\u8bae:<\/p>\n<ul>\n<li>\n<p>\u516c\u5171\u5e93\u5408\u5e76<\/p>\n<\/li>\n<li>\n<p>\u4e0d\u540c\u9875\u9762\u7684 js \u5206\u522b\u5408\u5e76( \u9488\u5bf9\u5355\u9875\u9762, \u5f02\u6b65\u52a0\u8f7d\u7ec4\u4ef6 )<\/p>\n<\/li>\n<li>\n<p>\u89c1\u673a\u884c\u4e8b, \u968f\u673a\u5e94\u53d8<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528\u5728\u7ebf\u7f51\u7ad9\u8fdb\u884c\u6587\u4ef6\u5408\u5e76<\/p>\n<\/li>\n<li>\n<p>\u6784\u5efa\u9636\u6bb5\u4f7f\u7528 nodejs \u5b9e\u73b0\u6587\u4ef6\u5408\u5e76<\/p>\n<\/li>\n<\/ul>\n<h2>\u4f7f\u7528 fis3 \u6784\u5efa\u5de5\u5177\u81ea\u52a8\u538b\u7f29\u5408\u5e76<\/h2>\n<h1>\u56fe\u7247\u4f18\u5316<\/h1>\n<h2>\u56fe\u7247\u4f18\u5316- \u56fe\u7247\u52a0\u8f7d\u4f18\u5316<\/h2>\n<ul>\n<li>\u539f\u751f\u7684\u56fe\u7247\u61d2\u52a0\u8f7d\u65b9\u6848 &lt; img loading=&quot;lazy&quot;<\/li>\n<li>\u7b2c\u4e09\u65b9\u56fe\u7247\u61d2\u52a0\u8f7d\u65b9\u6848<br \/>\nverlok\/lazyload<br \/>\nyall.js<br \/>\nBlazy<\/p>\n<h3>\u4f7f\u7528\u6e10\u8fdb\u5f0f\u56fe\u7247<\/h3>\n<\/li>\n<\/ul>\n<p><img data-original=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2024\/01\/2024010517220361.png\"  alt=\"\" \/><\/p>\n<noscript><img decoding=\"async\" src=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2024\/01\/2024010517220361.png\" alt=\"\" \/><\/p><\/noscript>\n<p><img data-original=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2024\/01\/2024010517224738.png\"  alt=\"\" \/><\/p>\n<noscript><img decoding=\"async\" src=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2024\/01\/2024010517224738.png\" alt=\"\" \/><\/p><\/noscript>\n<h3>\u4f7f\u7528\u54cd\u5e94\u5f0f\u56fe\u7247<\/h3>\n<ul>\n<li>Srcset \u5c5e\u6027\u7684\u4f7f\u7528<\/li>\n<li>Sizes \u5c5e\u6027\u7684\u4f7f\u7528<\/li>\n<li>picture \u7684\u4f7f\u7528<\/li>\n<\/ul>\n<p><img data-original=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2024\/01\/2024010517255123.png\"  alt=\"\" \/><\/p>\n<noscript><img decoding=\"async\" src=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2024\/01\/2024010517255123.png\" alt=\"\" \/><\/p><\/noscript>\n<h2>\u4e0d\u540c\u683c\u5f0f\u56fe\u7247\u5e38\u7528\u7684\u4e1a\u52a1\u573a\u666f<\/h2>\n<ul>\n<li>jpg \u6709\u635f\u538b\u7f29, \u538b\u7f29\u7387\u9ad8, <strong>\u4e0d\u652f\u6301\u900f\u660e<\/strong>\u3002\n<ul>\n<li>\u4f18\u70b9: \u538b\u7f29\u6bd4\u5f88\u9ad8, \u989c\u8272\u8272\u5f69\u753b\u8d28\u597d\u3002\u7f3a\u70b9: logo \u4e0d\u7528 jpeg\uff0c\u8fb9\u7f18\u611f\u7c97\u7cd9<\/li>\n<li>\u4f7f\u7528\u573a\u666f: \u8f6e\u64ad\u56fe<\/li>\n<\/ul>\n<\/li>\n<li>png\uff1a\u4f18\u70b9: \u652f\u6301<strong>\u900f\u660e<\/strong>\u80cc\u666f\u56fe\u7247\uff08\u7ebf\u6761, \u8fb9\u7f18, \u7ec6\u817b\u7a0b\u5ea6\uff09\uff0c\u6d4f\u89c8\u5668\u517c\u5bb9\u597d\u3002\u7f3a\u70b9: \u4fdd\u7559\u7ec6\u8282, \u4f53\u79ef\u5927\u3010\u5c0f\u7684\u56fe\u7247. \u56fe\u6807 logo\u3011<\/li>\n<li>webp \u538b\u7f29\u7a0b\u5ea6\u66f4\u597d, \u5728 ios webview \u6709\u517c\u5bb9\u6027\u95ee\u9898 ( \u5b89\u5353\u5168\u90e8 )<\/li>\n<li>svg \u77e2\u91cf\u56fe, \u5185\u5bb9\u5185\u5d4c, \u76f8\u5bf9\u8f83\u5c0f, <strong>\u56fe\u7247\u6837\u5f0f\u76f8\u5bf9\u7b80\u5355\u7684\u573a\u666f<\/strong>  ( logo )<\/li>\n<\/ul>\n<h3>css \u96ea\u78a7\u56fe<\/h3>\n<ul>\n<li>\u51cf\u5c11\u7f51\u7ad9 http \u8bf7\u6c42\u6570\u91cf<\/li>\n<li>\u7f3a\u70b9: \u6574\u5408\u56fe\u7247\u6bd4\u8f83\u5927\u65f6, \u4e00\u6b21\u52a0\u8f7d\u6bd4\u8f83\u6162<\/li>\n<\/ul>\n<h3>image inline<\/h3>\n<ul>\n<li>\u5c06\u56fe\u7247\u7684\u5185\u5bb9\u5185\u5d4c\u5230 html \u5f53\u4e2d<\/li>\n<li>\u51cf\u5c11\u7f51\u7ad9 http \u8bf7\u6c42\u6570\u91cf<\/li>\n<\/ul>\n<h3>\u77e2\u91cf\u56fe<\/h3>\n<ul>\n<li>svg \u8fdb\u884c\u77e2\u91cf\u56fe\u7684\u7ed8\u5236<\/li>\n<li>\u4f7f\u7528 iconfont \u89e3\u51b3 icon \u95ee\u9898<\/li>\n<\/ul>\n<h3>\u5728\u5b89\u5353\u4e0b\u4f7f\u7528 webpp<\/h3>\n<ul>\n<li>WebP \u7684\u4f18\u52bf\u4f53\u73b0\u5728\u5b83\u5177\u6709\u66f4\u4f18\u7684\u56fe\u50cf\u6570\u636e\u538b\u7f29\u7b97\u6cd5\uff0c\u80fd\u5e26\u6765\u66f4\u5c0f\u7684\u56fe\u7247\u4f53\u79ef\uff0c\u800c\u4e14\u62e5\u6709\u8089\u773c\u8bc6\u522b\u65e0\u5dee\u5f02\u7684\u56fe\u50cf\u8d28\u91cf\uff1b<\/li>\n<li>\u540c\u65f6\u5177\u5907\u4e86\u65e0\u635f\u548c\u6709\u635f\u7684\u538b\u7f29\u6a21\u5f0f\u3001Alpha \u900f\u660e\u4ee5\u53ca\u52a8\u753b\u7684\u7279\u6027\uff0c\u5728 JPEG \u548c PNG \u4e0a\u7684\u8f6c\u5316\u6548\u679c\u90fd\u975e\u5e38\u4f18\u79c0\u3001\u7a33\u5b9a\u548c\u7edf\u4e00\u3002<\/li>\n<li>\u6bd4 png \u4f53\u79ef\u66f4\u5c0f<\/li>\n<li>ie \u4e0d\u652f\u6301 \u517c\u5bb9\u6027\u4e0d\u597d, 80%<\/li>\n<\/ul>\n<h1>css \u548c js \u7684\u88c5\u8f7d\u4e0e\u6267\u884c<\/h1>\n<h2>HTML \u9875\u9762\u52a0\u8f7d\u6e32\u67d3\u7684\u8fc7\u7a0b<\/h2>\n<ul>\n<li>\u7406\u89e3\u6d4f\u89c8\u5668\u7aef html, css, js \u7684\u52a0\u8f7d\u8fc7\u7a0b<\/li>\n<li>\u7ed3\u5408 chrome \u7684\u80fd\u529b\u5b66\u4e60\u638c\u63e1 css, js \u52a0\u8f7d\u8fc7\u7a0b\u4e2d\u7684\u4f18\u5316\u70b9<\/li>\n<\/ul>\n<p>\u7279\u70b9<\/p>\n<ul>\n<li>\u987a\u5e8f\u6267\u884c, \u5e76\u53d1\u52a0\u8f7d\n<ul>\n<li>\u8bcd\u6cd5\u5206\u6790 <\/li>\n<li>\u5e76\u53d1\u52a0\u8f7d<\/li>\n<li>\u5e76\u53d1\u4e0a\u9650<\/li>\n<\/ul>\n<\/li>\n<li>\u662f\u5426\u963b\u585e<\/li>\n<li>\u4f9d\u8d56\u5173\u7cfb<\/li>\n<li>\u5f15\u5165\u65b9\u5f0f<\/li>\n<\/ul>\n<h2>css \u963b\u585e?<\/h2>\n<ul>\n<li>css head \u4e2d\u963b\u585e\u9875\u9762\u7684\u6e32\u67d3<\/li>\n<li>css \u963b\u585e js \u7684\u6267\u884c<\/li>\n<li>css \u4e0d\u963b\u585e\u5916\u90e8\u811a\u672c\u7684\u52a0\u8f7d<\/li>\n<\/ul>\n<h2>js \u963b\u585e?<\/h2>\n<ul>\n<li>\u76f4\u63a5\u5f15\u5165\u7684 js \u963b\u585e\u9875\u9762\u7684\u6e32\u67d3<\/li>\n<li>js \u4e0d\u963b\u585e\u8d44\u6e90\u7684\u52a0\u8f7d<\/li>\n<li>js \u987a\u5e8f\u6267\u884c, \u963b\u585e\u540e\u7eed js \u903b\u8f91\u7684\u6267\u884c<\/li>\n<\/ul>\n<h1>\u61d2\u52a0\u8f7d\u4e0e\u9884\u52a0\u8f7d<\/h1>\n<h2>\u61d2\u52a0\u8f7d\u539f\u7406<\/h2>\n<ul>\n<li>\u56fe\u7247\u8fdb\u5165\u53ef\u89c6\u533a\u57df\u4e4b\u540e\u8bf7\u6c42\u56fe\u7247\u8d44\u6e90\uff08\u52a8\u6001\u56fe\u7247\u7684 src \u7684\u5730\u5740\u662f\u5426\u771f\u5b9e\u7684, \u5426: \u53ef\u80fd\u4e3a 1px \u5360\u4f4d\u7b26\uff09 image \u6807\u7b7e\u7684 src \u88ab\u8bbe\u7f6e\u540e, \u5c31\u4f1a\u8bf7\u6c42\u8d44\u6e90<\/li>\n<li>\u5bf9\u4e8e\u7535\u5546\u7b49\u56fe\u7247\u5f88\u591a\uff0c\u9875\u9762\u5f88\u957f\u7684\u4e1a\u52a1\u573a\u666f\u9002\u7528<\/li>\n<li>\u51cf\u5c11\u65e0\u6548\u8d44\u6e90\u7684\u52a0\u8f7d<\/li>\n<li>\u5e76\u53d1\u52a0\u8f7d\u7684\u8d44\u6e90\u8fc7\u591a\u4f1a\u963b\u585e js \u7684\u52a0\u8f7d\uff0c\u5f71\u54cd\u7f51\u7ad9\u7684\u6b63\u5e38\u4f7f\u7528<\/li>\n<\/ul>\n<h2>\u9884\u52a0\u8f7d\u539f\u7406<\/h2>\n<ul>\n<li>\u56fe\u7247\u7b49\u9759\u6001\u8d44\u6e90\u5728\u4f7f\u7528\u4e4b\u524d\u7684\u63d0\u524d\u8bf7\u6c42<\/li>\n<li>\u8d44\u6e90\u4f7f\u7528\u5230\u65f6\u80fd\u4ece\u7f13\u5b58\u4e2d\u52a0\u8f7d\uff0c\u63d0\u5347\u7528\u6237\u4f53\u9a8c<\/li>\n<li>\u9875\u9762\u5c55\u793a\u7684\u4f9d\u8d56\u5173\u7cfb\u7ef4\u62a4<\/li>\n<\/ul>\n<h2>\u61d2\u52a0\u8f7d\u539f\u751f js \u548c zepto.lazyload<\/h2>\n<p>\u9700\u8981\u76d1\u542c scroll \u4e8b\u4ef6\uff0c\u5728 scroll \u4e8b\u4ef6\u7684\u56de\u8c03\u4e2d\uff0c\u53bb\u5224\u65ad\u6211\u4eec\u7684\u61d2\u52a0\u8f7d\u7684\u56fe\u7247\u662f\u5426\u8fdb\u5165\u53ef\u89c6\u533a\u57df<\/p>\n<h2>\u9884\u52a0\u8f7d\u539f\u751f js \u548c PreloadJS \u5b9e\u73b0<\/h2>\n<ul>\n<li>\n<p>1.\u4f7f\u7528 img \u6807\u7b7e\uff0cstyle \u6837\u5f0f display: none<\/p>\n<\/li>\n<li>\n<p>2.\u4f7f\u7528 Image \u5bf9\u8c61<br \/>\nvar image=new Image()<br \/>\nimage.src=&quot;<a href=\"https:\/\/xxxx\">https:\/\/xxxx<\/a>&quot;<\/p>\n<\/li>\n<li>\n<p>3.\u4f7f\u7528 XMLHttpRequest \u5bf9\u8c61<\/p>\n<\/li>\n<li>\n<p>4.\u4f7f\u7528 PreloadJS<br \/>\nnew createjs.LoadQueue(false)<br \/>\n??\u4e3a\u5565\u8981\u4f20\u53c2 false<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u4e8c\u8005\u672c\u8d28\u4e0a\u662f\u63a7\u5236\u56fe\u7247\u52a0\u8f7d\u7684\u65f6\u673a<\/strong><\/p>\n<p><strong>\u6743\u8861\u6d4f\u89c8\u5668\u672c\u8eab\u5177\u6709\u52a0\u8f7d\u8d44\u6e90\u7684\u80fd\u529b\uff0c\u8ba9\u8fd9\u80fd\u529b\u9971\u548c\uff0c\u5145\u5206\u4f7f\u7528\uff0c\u597d\u8ba9\u524d\u7aef\u6027\u80fd\u4f18\u5316\uff0c\u6709\u66f4\u597d\u7684\u4f53\u9a8c<\/strong><\/p>\n<h1>\u91cd\u7ed8\u548c\u56de\u6d41<\/h1>\n<h2>\u56de\u6d41\u4e0e\u91cd\u7ed8\uff0c\u5982\u4f55\u907f\u514d\u5e03\u5c40\u6296\u52a8<\/h2>\n<h3>\u5e03\u5c40\u548c\u7ed8\u5236<\/h3>\n<ul>\n<li>\u6e32\u67d3\u6811\u53ea\u5305\u542b\u7f51\u9875\u9700\u8981\u7684\u8282\u70b9<\/li>\n<li>\u5e03\u5c40\u8ba1\u7b97\u6bcf\u4e2a\u8282\u70b9\u7cbe\u786e\u7684\u4f4d\u7f6e\u548c\u5927\u5c0f -\u201c\u76d2\u6a21\u578b\u201d<\/li>\n<li>\u7ed8\u5236\u662f\u50cf\u7d20\u5316\u6bcf\u4e2a\u8282\u70b9\u7684\u8fc7\u7a0b<\/li>\n<\/ul>\n<h3>\u907f\u514d\u5e03\u5c40\u6296\u52a8\uff08layout thrashing\uff09<\/h3>\n<ul>\n<li>\u4f7f\u7528 FastDom \u6279\u91cf\u5bf9 DOM \u7684\u8bfb\u5199\u64cd\u4f5c\uff08eg\uff1a\u52a8\u6001\u4fee\u6539\u56fe\u7247\u5bbd\u5ea6\uff09<br \/>\n<img data-original=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2024\/01\/2024010416394884.png\"  alt=\"\" \/><\/li>\n<noscript><img decoding=\"async\" src=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2024\/01\/2024010416394884.png\" alt=\"\" \/><\/li><\/noscript>\n<\/ul>\n<h2>css \u6027\u80fd\u8ba9 javascript \u53d8\u6162\uff1f<\/h2>\n<ul>\n<li>eg: js \u5199\u4e86\u4e2a\u6b7b\u5faa\u73af, \u9875\u9762\u7a81\u7136\u5361\u6b7b\uff0cchome \u65e0\u54cd\u5e94<\/li>\n<li>css \u6838\u5fc3\u4f1a\u5f71\u54cd\u9875\u9762\u6837\u5f0f\u7684\u5c55\u793a,<\/li>\n<li>\u9891\u7e41\u89e6\u53d1<strong>\u91cd\u7ed8<\/strong>\u4e0e<strong>\u56de\u6d41<\/strong>\uff0c\u4f1a\u5bfc\u81f4 UI \u9891\u7e41\u6e32\u67d3\uff0c\u6700\u7ec8\u5bfc\u81f4 js \u53d8\u6162<\/li>\n<li>\u4e00\u4e2a\u7ebf\u7a0b=&gt;JavaScript \u89e3\u6790<\/li>\n<li>\u4e00\u4e2a\u7ebf\u7a0b=&gt;UI \u6e32\u67d3<\/li>\n<\/ul>\n<h2>\u4ec0\u4e48\u662f\u91cd\u7ed8\u4e0e\u56de\u6d41<\/h2>\n<p><strong>\u56de\u6d41\u5fc5\u5c06\u5f15\u8d77\u91cd\u7ed8\uff0c\u800c\u91cd\u7ed8\u4e0d\u4e00\u5b9a\u4f1a\u5f15\u8d77\u56de\u6d41<\/strong><\/p>\n<h3>\u56de\u6d41<\/h3>\n<ul>\n<li>\u5f53 render tree \u4e2d\u7684\u4e00\u90e8\u5206(\u6216\u5168\u90e8) \u56e0\u4e3a\u5143\u7d20\u7684<strong>\u89c4\u6a21\u5c3a\u5bf8, \u5e03\u5c40, \u9690\u85cf<\/strong>\u7b49\u6539\u53d8\u800c\u9700\u8981\u91cd\u65b0<strong>\u6784\u5efa<\/strong>\u3002\u8fd9\u5c31\u6210\u4e3a\u56de\u6d41\uff08reflow\uff09<\/li>\n<li>\u5f53\u9875\u9762\u5e03\u5c40\u548c\u51e0\u4f55\u5c5e\u6027\u6539\u53d8\u65f6\u5c31\u9700\u8981\u56de\u6d41<\/li>\n<\/ul>\n<h4>\u5f71\u54cd\u56de\u6d41\u7684\u64cd\u4f5c<\/h4>\n<ul>\n<li>\u6dfb\u52a0\/\u5220\u9664\u5143\u7d20<\/li>\n<li>display\uff1anone<\/li>\n<li>\u79fb\u52a8\u5143\u7d20\u4f4d\u7f6e<\/li>\n<li>\u64cd\u4f5c styles<\/li>\n<li>offsetLeft,scrollTop, clientWidth<\/li>\n<li>\u4fee\u6539\u6d4f\u89c8\u5668\u5927\u5c0f\uff0c\u5b57\u4f53\u5927\u5c0f<\/li>\n<\/ul>\n<h3>\u91cd\u7ed8<\/h3>\n<ul>\n<li>\u5f53 render tree \u4e2d\u7684\u4e00\u4e9b\u5143\u7d20\u9700\u8981\u66f4\u65b0\u5c5e\u6027\uff0c\u800c\u8fd9\u4e9b\u5c5e\u6027\u53ea\u662f\u5f71\u54cd\u5143\u7d20\u7684\u5916\u89c2\uff0c\u98ce\u683c\uff0c\u800c\u4e0d\u4f1a\u5f71\u54cd\u5e03\u5c40\u7684\uff0c\u6bd4\u5982 background-color\u3002\u5219\u5c31\u53eb\u79f0\u4e3a\u91cd\u7ed8\u3002<\/li>\n<\/ul>\n<h2>\u907f\u514d\u91cd\u7ed8\u56de\u6d41\u7684\u4e24\u79cd\u65b9\u6cd5<\/h2>\n<h3>1.\u907f\u514d\u4f7f\u7528\u89e6\u53d1\u91cd\u7ed8, \u56de\u6d41\u7684 CSS \u5c5e\u6027<\/h3>\n<ul>\n<li>\u2460\u89e6\u53d1\u9875\u9762\u91cd\u5e03\u5c40\u7684\u5c5e\u6027\uff08\u56de\u6d41\uff09\n<ul>\n<li>\u76d2\u5b50\u6a21\u578b\u76f8\u5173\u5c5e\u6027\u4f1a\u89e6\u53d1\u91cd\u5e03\u5c40<\/li>\n<li>\u5b9a\u4f4d\u5c5e\u6027\u53ca\u6d6e\u52a8\u4e5f\u4f1a\u91cd\u53d1\u91cd\u5e03\u5c40<\/li>\n<li>\u6539\u53d8\u8282\u70b9\u5185\u90e8\u6587\u5b57\u7ed3\u6784\u4e5f\u4f1a\u89e6\u53d1\u91cd\u5e03\u5c40<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img data-original=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2025\/07\/2025072411234749.png\"  alt=\"\" \/><\/p>\n<noscript><img decoding=\"async\" src=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2025\/07\/2025072411234749.png\" alt=\"\" \/><\/p><\/noscript>\n<ul>\n<li>\u2461\u53ea\u89e6\u53d1\u91cd\u7ed8\u7684\u5c5e\u6027<\/li>\n<\/ul>\n<p><img data-original=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2025\/07\/2025072411253422.png\"  alt=\"\" \/><\/p>\n<noscript><img decoding=\"async\" src=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2025\/07\/2025072411253422.png\" alt=\"\" \/><\/p><\/noscript>\n<h3>2.\u5c06\u91cd\u7ed8, \u56de\u6d41\u7684\u5f71\u54cd\u8303\u56f4\u9650\u5236\u5728\u5355\u72ec\u7684\u56fe\u5c42\u4e4b\u5185<\/h3>\n<p><img data-original=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2025\/07\/2025072411300015.png\"  alt=\"\" \/><\/p>\n<noscript><img decoding=\"async\" src=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2025\/07\/2025072411300015.png\" alt=\"\" \/><\/p><\/noscript>\n<ul>\n<li>\u5c06<strong>\u9891\u7e41\u91cd\u7ed8\u56de\u6d41<\/strong>\u7684 DOM \u5143\u7d20\u5355\u72ec\u4f5c\u4e3a\u4e00\u4e2a<strong>\u72ec\u7acb\u56fe\u5c42<\/strong>\uff0c\u90a3\u4e48\u8fd9\u4e2a DOM \u5143\u7d20\u548c\u91cd\u7ed8\u548c\u56de\u6d41\u7684\u5f71\u54cd<strong>\u53ea\u4f1a<\/strong>\u5728\u8fd9\u4e2a\u56fe\u5c42\u4e2d<\/li>\n<\/ul>\n<h4>\u5982\u4f55\u5c06 DOM \u5143\u7d20\u53d8\u6210\u65b0\u7684\u72ec\u7acb\u56fe\u5c42\uff1f<\/h4>\n<h4>Chrome \u521b\u5efa\u56fe\u5c42\u7684\u6761\u4ef6<\/h4>\n<ul>\n<li>1.3D \u6216\u900f\u89c6\u53d8\u6362 CSS \u5c5e\u6027(perspective transform)<\/li>\n<li>2.\u4f7f\u7528\u52a0\u901f\u89c6\u9891\u89e3\u7801\u7684&lt;video \u8282\u70b9<\/li>\n<li>3.\u62e5\u6709 3D(WebGL)\u4e0a\u4e0b\u6587\u6216\u52a0\u901f\u7684 2D \u4e0a\u4e0b\u6587\u7684&lt;canvas \u8282\u70b9<\/li>\n<li>4.\u6df7\u5408\u63d2\u4ef6(\u5982 Flash)<\/li>\n<li>5.\u5bf9\u81ea\u5df1\u7684 opacity \u505a CSS \u52a8\u753b\u6216\u4f7f\u7528\u4e00\u4e2a\u52a8\u753b webkit \u53d8\u6362\u7684\u5143\u7d20<\/li>\n<li>6.\u62e5\u6709\u52a0\u901f CSS \u8fc7\u6ee4\u5668\u7684\u5143\u7d20<\/li>\n<li>7.\u5143\u7d20\u6709\u4e00\u4e2a\u5305\u542b\u590d\u5408\u5c42\u7684\u540e\u4ee3\u8282\u70b9(\u4e00\u4e2a\u5143\u7d20\u62e5\u6709\u4e00\u4e2a\u5b50\u5143\u7d20\uff0c\u8be5\u5b50\u5143\u7d20\u5728\u81ea\u5df1\u7684\u5c42\u91cc)<\/li>\n<li>8.\u5143\u7d20\u6709\u4e00\u4e2a z-index \u8f83\u4f4e\u4e14\u5305\u542b\u4e00\u4e2a\u590d\u5408\u5c42\u7684\u5144\u5f1f\u5143\u7d20(\u6362\u53e5\u8bdd\u8bf4\u5c31\u662f\u8be5\u5143\u7d20\u5728\u590d\u5408\u5c42\u4e0a\u9762\u6e32\u67d3)<\/li>\n<\/ul>\n<h2>\u5b9e\u6218\u4f18\u5316\u70b9\u603b\u7ed3<\/h2>\n<ul>\n<li>1.\u7528 translate \u66ff\u4ee3 top \u6539\u53d8   ( top \u4f1a\u89e6\u53d1\u56de\u6d41\u4f46\u662f translate \u4e0d\u4f1a )<\/li>\n<li>2.\u7528 opacity \u66ff\u4ee3 visibility (\u51cf\u5c11\u91cd\u7ed8)<\/li>\n<li>3.\u4e0d\u8981\u4e00\u6761\u4e00\u6761\u5730\u4fee\u6539 DOM \u7684\u6837\u5f0f, \u9884\u5148\u5b9a\u4e49\u597d class(\u6837\u5f0f), \u7136\u540e\u4fee\u6539 DOM \u7684 className<\/li>\n<li>4.\u628a DOM \u79bb\u7ebf\u540e\u4fee\u6539\uff0c\u6bd4\u5982\uff1a\u5148\u628a DOM \u7ed9 display:none (\u6709\u4e00\u6b21 Reflow)\uff0c\u7136\u540e\u4f60\u4fee\u6539 100 \u6b21\uff0c\u7136\u540e\u518d\u628a\u5b83\u663e\u793a\u51fa\u6765<\/li>\n<li>5.\u4e0d\u8981\u628a<strong>DOM \u7ed3\u70b9\u7684\u5c5e\u6027\u503c<\/strong>\u653e\u5728\u4e00\u4e2a<strong>\u5faa\u73af<\/strong>\u91cc\u5f53\u6210\u5faa\u73af\u91cc\u7684\u53d8\u91cf ( offsetHeight  offsetWidth )<\/li>\n<li>6.\u4e0d\u8981\u4f7f\u7528 table \u5e03\u5c40\uff0c\u53ef\u80fd\u5f88\u5c0f\u7684\u4e00\u4e2a\u5c0f\u6539\u52a8\u4f1a\u9020\u6210\u6574\u4e2a table \u7684\u91cd\u65b0\u5e03\u5c40 ( \u5c3d\u91cf\u4f7f\u7528 div )<\/li>\n<li>7.\u52a8\u753b\u5b9e\u73b0\u7684\u901f\u5ea6\u7684\u9009\u62e9 ( \u5408\u9002\u52a8\u753b\u65f6\u95f4 )<\/li>\n<li>8.\u5bf9\u4e8e\u52a8\u753b\u65b0\u5efa\u56fe\u5c42<\/li>\n<li>9.\u542f\u7528 GPU \u786c\u4ef6\u52a0\u901f<\/li>\n<\/ul>\n<h3>1.\u7528 translate \u66ff\u4ee3 top \u6539\u53d8 2.\u7528 opacity \u66ff\u4ee3 visibility<\/h3>\n<ul>\n<li>opacity: \u6ca1\u6709 paint \u7684\u8fc7\u7a0b, \u56e0\u4e3a paint \u7684\u8fc7\u7a0b\u662f\u751f\u6210\u56fe\u5c42\uff0c\u4f46\u662f opacity \u5b9e\u9645\u4e0a\u662f\u76f4\u63a5\u6539\u53d8\u7684\u56fe\u5c42\u7684 alpha \u901a\u9053, \u6240\u4ee5\u4e0d\u6d89\u53ca\u56fe\u5c42\u7684\u91cd\u7ed8<\/li>\n<\/ul>\n<pre class=\"prettyprint linenums\" ><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;en&quot;&gt;\n&lt;head&gt;\n    &lt;title&gt;1.\u7528 translate \u66ff\u4ee3 top \u6539\u53d8 2.\u7528 opacity \u66ff\u4ee3 visibility&lt;\/title&gt;\n    &lt;meta charset=&quot;UTF-8&quot;&gt;&lt;\/meta&gt;\n    &lt;style&gt;\n        #rect {\n            width: 100px;\n            height: 100px;\n            background-color: blue;\n            \/*1.*\/\n            \/*position: relative;*\/\n            \/*top: 0;*\/\n\n            \/*transform: translateY(0);*\/\n\n            \/*2*\/\n            opacity: 1;\n            transform: translateZ(0);\n        }\n    &lt;\/style&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;div id=&quot;rect&quot;&gt;&lt;\/div&gt;\n&lt;script&gt;\n    setTimeout(() =&gt; {\n        \/\/ document.getElementById(&#039;rect&#039;).style.transform = &#039;translateY(100px)&#039;\n        \/\/ 2\n        document.getElementById(&#039;rect&#039;).style.opacity = &#039;0&#039;\n    }, 2000)\n&lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<h3>3.\u5355\u72ec class \u6837\u5f0f<\/h3>\n<pre class=\"prettyprint linenums\" ><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;en&quot;&gt;\n&lt;head&gt;\n    &lt;title&gt;3.\u4e0d\u8981\u4e00\u6761\u4e00\u6761\u5730\u4fee\u6539 DOM \u7684\u6837\u5f0f, \u9884\u5148\u5b9a\u4e49\u597d class, \u7136\u540e\u4fee\u6539 DOM \u7684 className&lt;\/title&gt;\n    &lt;meta charset=&quot;UTF-8&quot;&gt;&lt;\/meta&gt;\n    &lt;style&gt;\n        #rect {\n            position: relative;\n            width: 100px;\n            height: 100px;\n            background-color: blue;\n            opacity: 1;\n        }\n        #rect.action{\n            \/*#rect.action \u63d0\u9ad8\u6837\u5f0f\u4f18\u5148\u7ea7*\/\n            width: 200px;\n            height: 300px;\n            left: 300px;\n            top: 200px;\n        }\n    &lt;\/style&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;div id=&quot;rect&quot;&gt;&lt;\/div&gt;\n&lt;script&gt;\n    setTimeout(() =&gt; {\n        document.getElementById(&#039;rect&#039;).className = &#039;action&#039;\n    }, 2000)\n&lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<h3>5.\u4e0d\u8981\u628a DOM \u7ed3\u70b9\u7684\u5c5e\u6027\u503c\u653e\u5728\u4e00\u4e2a\u5faa\u73af\u91cc\u5f53\u6210\u5faa\u73af\u91cc\u7684\u53d8\u91cf<\/h3>\n<pre class=\"prettyprint linenums\" ><code>&lt;script&gt;\n    var doms=[]\/\/\u901a\u8fc7\u9009\u62e9\u5668\u9009\u62e9\u51fa\u4e86\u4e00\u4e2a dom \u5143\u7d20\u7684\u6570\u7ec4\n    var domsTop=[]\n    var clientHeight=document.body.clientHeight\/\/\u83b7\u53d6\u53ef\u89c6\u533a\u57df\u7684\u9ad8\u5ea6\n    \/\/\u53bb\u6839\u636e\u5f53\u524d\u9875\u9762\u7684\u53ef\u89c6\u533a\u57df\u7684\u9ad8\u5ea6,\u53bb\u8ba1\u7b97\u8fd9\u4e2a dom \u5143\u7d20\u7684\u4f4d\u7f6e\n    for(var i=0;i&lt;doms.length;i++){\n        \/\/ domsTop.push(document.body.clientHeight+i*100)\/\/\u6d4f\u89c8\u5668\u7684\u5e03\u5c40\u7f13\u5b58\u88ab\u9891\u7e41\u5237\u65b0\uff0c\u5bfc\u81f4\u6bcf\u6b21\u8bbf\u95ee DOM \u5c5e\u6027\u65f6\u90fd\u9700\u8981\u91cd\u65b0\u8ba1\u7b97\uff0c\u4ece\u800c\u5f71\u54cd\u6027\u80fd\n        domsTop.push(clientHeight+i*100)\n    }\n&lt;\/script&gt;<\/code><\/pre>\n<h3>7.\u52a8\u753b\u5b9e\u73b0\u7684\u901f\u5ea6\u7684\u9009\u62e9<\/h3>\n<pre class=\"prettyprint linenums\" ><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;en&quot;&gt;\n&lt;head&gt;\n    &lt;title&gt;7.\u52a8\u753b\u5b9e\u73b0\u7684\u901f\u5ea6\u7684\u9009\u62e9  &lt;\/title&gt;\n    &lt;meta charset=&quot;UTF-8&quot;&gt;&lt;\/meta&gt;\n    &lt;style&gt;\n        #rect {\n            position: relative;\n            top: 0;\n            left: 0;\n            width: 100px;\n            height: 100px;\n            background-color: blue;\n            opacity: 1;\n        }\n    &lt;\/style&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;div id=&quot;rect&quot;&gt;&lt;\/div&gt;\n&lt;script&gt;\n    var distance = 0;\n    setInterval(()=&gt;{\/\/\u5e73\u6ed1\u5ea6\u9ad8, \u6d41\u7545, \u4f46\u662f\u8017\u6027\u80fd\u9ad8,\u56de\u6d41\u91cd\u7ed8\u6b21\u6570\u591a\n        distance ++;\n        document.getElementById(&#039;rect&#039;).style.top=distance+&#039;px&#039;;\n        document.getElementById(&#039;rect&#039;).style.left=distance+&#039;px&#039;;\n    },100)\n&lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<h3>8will-change \u662f\u4e00\u4e2a CSS \u5c5e\u6027\uff0c<\/h3>\n<ul>\n<li>\u7528\u4e8e\u544a\u8bc9\u6d4f\u89c8\u5668\u67d0\u4e2a\u5143\u7d20\u5728\u672a\u6765\u53ef\u80fd\u4f1a\u53d1\u751f\u54ea\u4e9b\u53d8\u5316\u3002\u8fd9\u53ef\u4ee5\u5e2e\u52a9\u6d4f\u89c8\u5668\u4f18\u5316\u6e32\u67d3\u6027\u80fd\uff0c\u63d0\u524d\u505a\u4e00\u4e9b\u51c6\u5907\u5de5\u4f5c\uff0c\u4ece\u800c\u63d0\u9ad8\u6027\u80fd\u3002<\/li>\n<\/ul>\n<h4>will-change: transform; \u548c transform: translateZ(0);<\/h4>\n<p>\u8fd9\u6bb5 CSS \u4ee3\u7801\u7528\u4e8e\u4f18\u5316\u52a8\u753b\u6027\u80fd\uff1a<\/p>\n<ul>\n<li><strong>will-change: transform<\/strong>\uff1a\u63d0\u524d\u544a\u77e5\u6d4f\u89c8\u5668\u5143\u7d20\u5c06\u8981\u53d1\u751f\u53d8\u6362\uff0c\u8ba9\u6d4f\u89c8\u5668\u9884\u5148\u8fdb\u884c\u6027\u80fd\u4f18\u5316<\/li>\n<\/ul>\n<h3>9.\u542f\u7528 GPU \u786c\u4ef6\u52a0\u901f<\/h3>\n<ul>\n<li>\n<p><strong>transform: translateZ(0)\uff1a<\/strong>\u521b\u5efa\u786c\u4ef6\u52a0\u901f\u4e0a\u4e0b\u6587\uff0c\u5c06\u5143\u7d20\u63d0\u5347\u5230\u65b0\u7684\u5408\u6210\u5c42\uff0c\u907f\u514d\u91cd\u7ed8\u548c\u56de\u6d41\uff0c\u63d0\u9ad8\u52a8\u753b\u6d41\u7545\u5ea6<br \/>\n\u4e24\u8005\u7ed3\u5408\u4f7f\u7528\u53ef\u4ee5\u663e\u8457\u63d0\u5347 CSS \u52a8\u753b\u548c\u53d8\u6362\u7684\u6e32\u67d3\u6027\u80fd\u3002<\/p>\n<\/li>\n<li>\n<p><strong>transform: translate3d(0,0,0)\uff1a<\/strong>  \u4e0d\u80fd\u6ee5\u7528,<br \/>\n\u521b\u5efa\u4e00\u4e2a 3D \u53d8\u6362\u4e0a\u4e0b\u6587<br \/>\n\u5f3a\u5236\u6d4f\u89c8\u5668\u5c06\u8be5\u5143\u7d20\u63d0\u5347\u5230\u72ec\u7acb\u7684\u5408\u6210\u5c42<br \/>\n\u89e6\u53d1 GPU \u786c\u4ef6\u52a0\u901f\uff0c\u4f7f\u52a8\u753b\u66f4\u52a0\u6d41\u7545<\/p>\n<\/li>\n<\/ul>\n<h1>\u6d4f\u89c8\u5668\u5b58\u50a8<\/h1>\n<h2>cookies<\/h2>\n<ul>\n<li><strong>\u56e0\u4e3a HTTP \u8bf7\u6c42\u65e0\u72b6\u6001\uff0c\u6240\u4ee5\u9700\u8981 cookie \u53bb\u7ef4\u6301\u5ba2\u6237\u7aef\u72b6\u6001<\/strong><\/li>\n<li>cookie \u7684\u751f\u6210\u65b9\u5f0f\uff1a\n<ul>\n<li>http response header \u4e2d\u7684 set-cookie<\/li>\n<li>js \u4e2d\u53ef\u4ee5\u901a\u8fc7 document.cookie \u53ef\u4ee5\u8bfb\u5199 cookie<\/li>\n<\/ul>\n<\/li>\n<li>\u4e24\u79cd\u4f5c\u7528\n<ul>\n<li>\u2460\u7528\u4e8e\u6d4f\u89c8\u5668\u7aef\u548c\u670d\u52a1\u5668\u7aef\u7684\u4ea4\u4e92<\/li>\n<li>\u2461\u5ba2\u6237\u7aef\u81ea\u8eab\u6570\u636e\u7684\u5b58\u50a8<\/li>\n<\/ul>\n<\/li>\n<li>\u8fc7\u671f\u65f6\u95f4\uff1aexpire<\/li>\n<\/ul>\n<h3>cookie \u5b58\u50a8\u7684\u9650\u5236<\/h3>\n<ul>\n<li>\u4ec5\u4ec5\u4f5c\u4e3a\u6d4f\u89c8\u5668\u5b58\u50a8\uff0c\u5927\u5c0f 4KB \u5de6\u53f3<\/li>\n<li>\u9700\u8981\u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4 expire<\/li>\n<li>cookie \u5b58\u50a8\u6570\u636e\u80fd\u529b\u88ab localstorage \u66ff\u4ee3<\/li>\n<li>cookie \u4e0d\u652f\u6301 js \u8bfb\u5199----httponly<\/li>\n<li>cookie \u4e2d\u5728\u76f8\u5173\u57df\u540d\u4e0b\u9762--cdn \u7684\u6d41\u91cf\u635f\u8017\n<ul>\n<li>\u89e3\u51b3\u65b9\u6cd5: cdn \u7684\u57df\u540d \u548c\u4e3b\u7ad9\u7684\u57df\u540d\u8981\u5206\u5f00<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>localStorage<\/h2>\n<ul>\n<li>HTML5 \u8bbe\u8ba1\u51fa\u6765\u4e13\u95e8\u7528\u4e8e\u6d4f\u89c8\u5668\u5b58\u50a8\u7684<\/li>\n<li>\u5927\u5c0f\u4e3a 5M \u5de6\u53f3<\/li>\n<li>\u4ec5\u5728\u5ba2\u6237\u7aef\u4f7f\u7528\uff0c\u4e0d\u548c\u670d\u52a1\u7aef\u8fdb\u884c\u901a\u4fe1<\/li>\n<li>\u63a5\u53e3\u5c01\u88c5\u8f83\u597d<\/li>\n<li>\u6d4f\u89c8\u5668\u672c\u5730\u7f13\u5b58\u65b9\u6848<\/li>\n<\/ul>\n<h2>sessionStorage<\/h2>\n<ul>\n<li>\u4f1a\u8bdd\u7ea7\u522b\u7684\u6d4f\u89c8\u5668\u5b58\u50a8<\/li>\n<li>\u5927\u5c0f\u4e3a 5M \u5de6\u53f3<\/li>\n<li>\u4ec5\u5728\u5ba2\u6237\u7aef\u4f7f\u7528\uff0c\u4e0d\u548c\u670d\u52a1\u7aef\u8fdb\u884c\u901a\u4fe1<\/li>\n<li>\u63a5\u53e3\u5c01\u88c5\u8f83\u597d<\/li>\n<li>\u5bf9\u4e8e\u8868\u5355\u4fe1\u606f\u7684\u7ef4\u62a4 \uff08\u591a\u9875\u9762\u5207\u6362\u65f6\uff09<\/li>\n<\/ul>\n<h2>IndexedDB<\/h2>\n<ul>\n<li>IndexedDB \u662f\u4e00\u79cd\u4f4e\u7ea7 API\uff0c\u7528\u4e8e\u5ba2\u6237\u7aef\u5b58\u50a8\u5927\u91cf\u7ed3\u6784\u5316\u6570\u636e\u3002\u8be5 API \u4f7f\u7528\u7d22\u5f15\u6765\u5b9e\u73b0\u5bf9\u8be5\u6570\u636e\u7684\u9ad8\u6027\u80fd\u641c\u7d22\u3002\u867d\u7136 WebStorage \u5bf9\u4e8e\u5b58\u50a8\u8f83\u5c11\u91cf\u7684\u6570\u636e\u5f88\u6709\u7528\uff0c\u4f46\u5bf9\u4e8e\u5b58\u50a8\u66f4\u5927\u91cf\u7684\u7ed3\u6784\u5316\u6570\u636e\u6765\u8bf4\uff0c\u8fd9\u79cd\u65b9\u6cd5\u4e0d\u592a\u6709\u7528\u3002IndexedDB \u63d0\u4f9b\u4e86\u4e00\u4e2a\u89e3\u51b3\u65b9\u6848\u3002<\/li>\n<li>\u4e3a\u5e94\u7528\u521b\u5efa\u79bb\u7ebf\u7248\u672c<\/li>\n<\/ul>\n<h2>PWA<\/h2>\n<ul>\n<li>\u53ef\u9760\uff1a\u5728\u6ca1\u6709\u7f51\u7edc\u7684\u73af\u5883\u4e2d\u4e5f\u80fd\u63d0\u4f9b\u57fa\u672c\u7684\u9875\u9762\u8bbf\u95ee\uff0c\u800c\u4e0d\u4f1a\u51fa\u73b0\u201c\u672a\u8fde\u63a5\u5230\u4e92\u8054\u7f51\u201d\u7684\u9875\u9762<\/li>\n<li>\u5feb\u901f\uff1a\u9488\u5bf9\u7f51\u9875\u6e32\u67d3\u53ca\u7f51\u7edc\u6570\u636e\u8bbf\u95ee\u6709\u8f83\u597d\u4f18\u5316<\/li>\n<li>\u878d\u5165\uff08Engaging\uff09\uff1a\u5e94\u7528\u53ef\u4ee5\u88ab\u589e\u52a0\u5230\u624b\u673a\u684c\u9762\uff0c\u5e76\u4e14\u548c\u666e\u901a\u5e94\u7528\u4e00\u6837\u6709\u5168\u5c4f\u3001\u63a8\u9001\u7b49\u7279\u6027\u3002<\/li>\n<li>lighthouse<\/li>\n<\/ul>\n<h2>Service Worker<\/h2>\n<ul>\n<li>\u662f\u4e00\u4e2a\u811a\u672c\uff0c\u6d4f\u89c8\u5668\u72ec\u7acb\u4e8e\u5f53\u524d\u7f51\u9875\uff0c\u5c06\u5176\u5728\u540e\u53f0\u8fd0\u884c\uff0c\u4e3a\u5b9e\u73b0\u4e00\u4e9b\u4e0d\u4f9d\u8d56\u9875\u9762\u6216\u8005\u7528\u6237\u4ea4\u4e92\u7684\u7279\u6027\u6253\u5f00\u4e86\u4e00\u6247\u5927\u95e8\u3002\u5728\u672a\u6765\u8fd9\u4e9b\u7279\u6027\u5c06\u5305\u62ec\u63a8\u9001\u6d88\u606f\uff0c\u80cc\u666f\u540e\u53f0\u540c\u6b65\uff0cgeofencing(\u5730\u7406\u56f4\u680f\u5b9a\u4f4d)\uff0c\u4f46\u5b83\u5c06\u63a8\u51fa\u7684\u7b2c\u4e00\u4e2a\u9996\u8981\u7279\u6027\uff0c\u5c31\u662f<strong>\u62e6\u622a<\/strong>\u548c<strong>\u5904\u7406<\/strong>\u7f51\u7edc\u8bf7\u6c42\u7684\u80fd\u529b\uff0c\u5305\u62ec\u4ee5\u7f16\u7a0b\u65b9\u5f0f\u6765\u7ba1\u7406\u88ab\u7f13\u5b58\u7684\u54cd\u5e94\u3002<\/li>\n<li>\u53ef\u4ee5\u5b9e\u73b0:\n<ul>\n<li>1.\u4f7f\u7528\u7f13\u5b58\u5b8c\u6210\u5f53\u524d PWA \u79bb\u7ebf\u5e94\u7528\u7684\u80fd\u529b<\/li>\n<li>2.\u548c\u4e3b\u9875\u9762\u7684\u901a\u4fe1\uff0c\uff08\u9875\u9762\u4e2d\u6709\u975e\u5e38\u5927\u7684\u6570\u636e\u5904\u7406\uff0c\u975e\u5e38\u5927\u7684\u903b\u8f91\u8fd0\u7b97---\u4e0d\u4f9d\u8d56\u9875\u9762\u6216\u8005\u7528\u6237\u4ea4\u4e92\u7684\u7279\u6027\uff0c\u53ef\u4ee5\u5728\u540e\u53f0\u8fd0\u884c\uff0c\u4e0d\u963b\u788d\u4e3b\u7ebf\u7a0b\u7684\u6267\u884c\uff09<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>\u5e94\u7528:<\/strong><\/p>\n<ul>\n<li>1.\u4f7f\u7528\u62e6\u622a\u548c\u5904\u7406\u7f51\u7edc\u8bf7\u6c42\u7684\u80fd\u529b\uff0c\u53bb\u5b9e\u73b0\u4e00\u4e2a\u79bb\u7ebf\u5e94\u7528<\/li>\n<li>2.\u4f7f\u7528 Service Worker \u5728\u540e\u53f0\u8fd0\u884c\u540c\u65f6\u80fd\u548c\u9875\u9762\u901a\u4fe1\u7684\u80fd\u529b, \u53bb\u5b9e\u73b0\u5927\u89c4\u6a21\u540e\u53f0\u6570\u636e\u7684\u5904\u7406<\/li>\n<\/ul>\n<h2>Cache-Control<\/h2>\n<p>\u662f HTTP \u534f\u8bae\u4e2d\u7684\u4e00\u4e2a\u54cd\u5e94\u5934\/\u8bf7\u6c42\u5934\uff0c\u7528\u6765\u63a7\u5236\u7f13\u5b58\u884c\u4e3a\u3002\u5b83\u53ef\u4ee5\u51b3\u5b9a\u6d4f\u89c8\u5668\u3001CDN\u3001\u4ee3\u7406\u670d\u52a1\u5668\u7b49\u4e2d\u95f4\u7f13\u5b58\u7684\u5b58\u50a8\u65b9\u5f0f\u548c\u6709\u6548\u65f6\u95f4\u3002<\/p>\n<ul>\n<li>max-age:\n<ul>\n<li>\u6307\u5b9a\u8d44\u6e90\u5728 \u7f13\u5b58\u4e2d\u7684\u6700\u5927\u5b58\u6d3b\u65f6\u95f4\uff08\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff09\u3002<\/li>\n<li>\u5728 max-age \u6709\u6548\u671f\u5185\uff0c\u6d4f\u89c8\u5668\u6216\u4ee3\u7406\u4f1a\u76f4\u63a5\u7528\u7f13\u5b58\uff0c\u4e0d\u4f1a\u53bb\u8bf7\u6c42\u670d\u52a1\u5668\u3002<\/li>\n<li>1h: 3600s,  1 \u5929 86400s,  <\/li>\n<li>0s \u7b49\u4ef7\u4e8e Expires: 0 [\u8868\u793a\u5ba2\u6237\u7aef\u53ea\u63a5\u53d7\u6700\u65b0\u8d44\u6e90\uff0c\u4e0d\u8981\u7528\u7f13\u5b58\u3002]<\/li>\n<\/ul>\n<\/li>\n<li>s-maxage<br \/>\n\u4ec5\u5171\u4eab\u7f13\u5b58\uff08CDN\u3001\u4ee3\u7406\uff09\u4f18\u5148\u7ea7\u6bd4 max-age \u9ad8<\/li>\n<li>no-cache<br \/>\n\u4e0d\u662f\u201c\u4e0d\u7f13\u5b58\u201d\uff0c\u800c\u662f \u53ef\u4ee5\u7f13\u5b58\uff0c\u4f46\u7528\u4e4b\u524d\u5fc5\u987b\u5411\u670d\u52a1\u5668\u786e\u8ba4\u662f\u5426\u8fc7\u671f\u3002<br \/>\n\u5b83\u4f9d\u8d56 \u534f\u5546\u7f13\u5b58\uff08ETag \/ Last-Modified\uff09\u3002<\/li>\n<li>no-store<br \/>\n\u5b8c\u5168\u4e0d\u7f13\u5b58\uff0c\u8fde\u78c1\u76d8\/\u5185\u5b58\u90fd\u4e0d\u4fdd\u5b58\uff08\u6700\u4e25\u683c\uff0c\u5e38\u7528\u4e8e\u654f\u611f\u4fe1\u606f\uff09<\/li>\n<li>public\n<ul>\n<li>\u8d44\u6e90\u53ef\u4ee5\u88ab \u4efb\u4f55\u7f13\u5b58 \u5b58\u50a8\uff1a\u6d4f\u89c8\u5668\u7f13\u5b58\u3001\u4ee3\u7406\u7f13\u5b58\uff08CDN\u3001\u4ee3\u7406\u670d\u52a1\u5668\u3001\u53cd\u5411\u4ee3\u7406\u7b49\uff09\u3002<\/li>\n<li>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5927\u90e8\u5206\u9759\u6001\u8d44\u6e90\uff08\u56fe\u7247\u3001CSS\u3001JS\uff09\u90fd\u662f public\u3002<\/li>\n<\/ul>\n<\/li>\n<li>private\n<ul>\n<li>\u8d44\u6e90\u53ea\u80fd\u88ab \u5355\u4e2a\u7528\u6237\u7684\u6d4f\u89c8\u5668\u7f13\u5b58\uff0c\u5171\u4eab\u7f13\u5b58\uff08CDN\/\u4ee3\u7406\uff09\u4e0d\u80fd\u5b58\u3002<\/li>\n<li>\u9002\u5408\u548c\u7528\u6237\u8eab\u4efd\u5f3a\u76f8\u5173\u7684\u6570\u636e\u3002<\/li>\n<li>\u5e38\u7528\u4e8e \u7528\u6237\u4e2a\u4eba\u4e3b\u9875\u3001\u8d2d\u7269\u8f66\u3001\u8d26\u6237\u4fe1\u606f \u7b49\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>Expires<\/h2>\n<ul>\n<li>\u662f HTTP\/1.0 \u7684\u7f13\u5b58\u63a7\u5236\u5934\uff0c\u7528\u4e8e\u6307\u5b9a\u4e00\u4e2a \u7edd\u5bf9\u7684\u8fc7\u671f\u65f6\u95f4\uff08GMT \u65f6\u95f4\uff09\u3002<\/li>\n<li>\u5728\u8fc7\u671f\u65f6\u95f4\u4e4b\u524d\uff0c\u6d4f\u89c8\u5668\u6216\u4ee3\u7406\u7f13\u5b58\u53ef\u4ee5\u76f4\u63a5\u4ece\u6d4f\u89c8\u5668\u7f13\u5b58\u53d6\u6570\u636e\uff0c\u4e0d\u7528\u53bb\u670d\u52a1\u5668\u8bf7\u6c42\u3002<\/li>\n<\/ul>\n<h2>last-modified \u7f3a\u70b9<\/h2>\n<ul>\n<li>\u67d0\u4e9b\u670d\u52a1\u7aef\u4e0d\u80fd\u83b7\u53d6\u7cbe\u786e\u7684\u4fee\u6539\u65f6\u95f4<\/li>\n<li>\u6587\u4ef6\u4fee\u6539\u65f6\u95f4\u6539\u4e86, \u4f46\u6587\u4ef6\u5185\u5bb9\u5374\u6ca1\u6709\u53d8<\/li>\n<\/ul>\n<p><img data-original=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2025\/08\/2025082210152714.png\"  alt=\"\" \/><br \/>\n<noscript><img decoding=\"async\" src=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2025\/08\/2025082210152714.png\" alt=\"\" \/><br \/><\/noscript>\n<img data-original=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2025\/08\/2025082210165065.png\"  alt=\"\" \/><\/p>\n<noscript><img decoding=\"async\" src=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2025\/08\/2025082210165065.png\" alt=\"\" \/><\/p><\/noscript>\n<h2>\u603b\u7ed3\u7f13\u5b58\u7b56\u7565\u573a\u666f\u901f\u67e5\u8868<\/h2>\n<p><img data-original=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2025\/08\/2025082215593477.png\"  alt=\"\" \/><\/p>\n<noscript><img decoding=\"async\" src=\"https:\/\/blog.odjbinail.cn\/wp-content\/uploads\/2025\/08\/2025082215593477.png\" alt=\"\" \/><\/p><\/noscript>\n<h2>\u5b9e\u6218<\/h2>\n","protected":false},"excerpt":{"rendered":"<p>\u8d44\u6e90\u5408\u5e76\u4e0e\u538b\u7f29 \u7406\u89e3\u51cf\u5c11 http \u8bf7\u6c42\u6570\u91cf\u548c\u51cf\u5c11\u8bf7\u6c42\u8d44\u6e90\u5927\u5c0f\u4e24\u4e2a\u4f18\u5316\u8981\u70b9 \u638c\u63e1\u538b\u7f29\u4e8e\u5408\u5e76\u7684\u539f\u7406 \u638c\u63e1\u901a\u8fc7\u5728\u7ebf [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4923","post","type-post","status-publish","format-standard","hentry","category-1"],"_links":{"self":[{"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=\/wp\/v2\/posts\/4923","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4923"}],"version-history":[{"count":79,"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=\/wp\/v2\/posts\/4923\/revisions"}],"predecessor-version":[{"id":5054,"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=\/wp\/v2\/posts\/4923\/revisions\/5054"}],"wp:attachment":[{"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4923"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4923"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4923"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}