{"id":261,"date":"2026-09-21T10:19:46","date_gmt":"2026-09-21T02:19:46","guid":{"rendered":"https:\/\/yykcj.com\/?p=261"},"modified":"2026-09-21T10:19:46","modified_gmt":"2026-09-21T02:19:46","slug":"web-%e5%ad%97%e4%bd%93%e4%bc%98%e5%8c%96%e5%ae%9e%e6%88%98%ef%bc%9a%e4%bb%8e-foit-%e5%88%b0-cls-%e7%9a%84%e5%ae%8c%e6%95%b4%e6%80%a7%e8%83%bd%e8%b0%83%e4%bc%98%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/yykcj.com\/?p=261","title":{"rendered":"Web \u5b57\u4f53\u4f18\u5316\u5b9e\u6218\uff1a\u4ece FOIT \u5230 CLS \u7684\u5b8c\u6574\u6027\u80fd\u8c03\u4f18\u6307\u5357"},"content":{"rendered":"<h2>\u4e3a\u4ec0\u4e48\u4f60\u7684\u7f51\u7ad9\u8fd8\u5728\u88ab\u5b57\u4f53\u62d6\u6162\uff1f<\/h2>\n<p>\u5728 Web \u6027\u80fd\u4f18\u5316\u4e2d\uff0c\u5b57\u4f53\u5f80\u5f80\u662f\u6700\u5bb9\u6613\u88ab\u5ffd\u89c6\u7684\u4e00\u73af\u3002\u4e00\u4e2a 300KB \u7684\u4e2d\u6587\u5b57\u4f53\u6587\u4ef6\uff0c\u53ef\u80fd\u8ba9\u9996\u5c4f\u6e32\u67d3\u5ef6\u8fdf 1 \u79d2\u4ee5\u4e0a\uff1b\u4e00\u4e2a\u672a\u4f18\u5316\u7684 <code>@font-face<\/code> \u58f0\u660e\uff0c\u53ef\u80fd\u5bfc\u81f4\u6587\u5b57\u957f\u65f6\u95f4\u4e0d\u53ef\u89c1\uff08FOIT\uff09\u6216\u7a81\u7136\u8df3\u52a8\uff08FOUT\uff09\u3002\u66f4\u9690\u853d\u7684\u662f\uff0c\u5b57\u4f53\u5207\u6362\u5f15\u53d1\u7684\u5e03\u5c40\u504f\u79fb\uff08CLS\uff09\u4f1a\u76f4\u63a5\u62c9\u4f4e Core Web Vitals \u8bc4\u5206\u3002<\/p>\n<p>\u672c\u6587\u5c06\u4ece\u5b9e\u9645\u573a\u666f\u51fa\u53d1\uff0c\u5e26\u4f60\u4e00\u6b65\u6b65\u5b8c\u6210\u5b57\u4f53\u6027\u80fd\u4f18\u5316\u3002\u8bfb\u5b8c\u4f60\u5c06\u638c\u63e1\uff1a<\/p>\n<ul>\n<li>\u5982\u4f55\u7cbe\u51c6\u5206\u6790\u5b57\u4f53\u52a0\u8f7d\u74f6\u9888<\/li>\n<li>\u5b57\u4f53\u5b50\u96c6\u5316\u4e0e\u683c\u5f0f\u9009\u62e9\u7684\u6700\u4f73\u5b9e\u8df5<\/li>\n<li>\u9884\u52a0\u8f7d\u3001<code>font-display<\/code> \u4e0e CSS \u5ea6\u91cf\u8986\u76d6\u7684\u7ec4\u5408\u62f3<\/li>\n<li>\u52a8\u6001\u5b57\u4f53\u7684\u6309\u9700\u52a0\u8f7d\u7b56\u7565<\/li>\n<\/ul>\n<h2>1. \u8bca\u65ad\uff1a\u4f60\u7684\u5b57\u4f53\u5230\u5e95\u6162\u5728\u54ea\u91cc\uff1f<\/h2>\n<p>\u4f18\u5316\u4e4b\u524d\uff0c\u5148\u6d4b\u91cf\u3002\u6253\u5f00 Chrome DevTools \u7684 <strong>Network<\/strong> \u9762\u677f\uff0c\u7b5b\u9009 <code>Font<\/code> \u7c7b\u578b\uff0c\u89c2\u5bdf\uff1a<\/p>\n<ul>\n<li>\u5b57\u4f53\u6587\u4ef6\u5927\u5c0f\uff08\u901a\u5e38\u4e2d\u6587\u5b57\u4f53 2-10MB\uff0c\u82f1\u6587\u5b57\u4f53 20-100KB\uff09<\/li>\n<li>\u52a0\u8f7d\u65f6\u95f4\u4e0e TTFB<\/li>\n<li>\u662f\u5426\u963b\u585e\u4e86\u6587\u672c\u6e32\u67d3<\/li>\n<\/ul>\n<p>\u66f4\u4e13\u4e1a\u7684\u65b9\u5f0f\u662f\u4f7f\u7528 <strong>Lighthouse<\/strong> \u7684\u201c\u907f\u514d\u5de8\u5927\u7684\u7f51\u7edc\u8d1f\u8f7d\u201d\u548c\u201c\u786e\u4fdd\u6587\u672c\u5728 Web \u5b57\u4f53\u52a0\u8f7d\u671f\u95f4\u4fdd\u6301\u53ef\u89c1\u201d\u5ba1\u8ba1\u9879\u3002<\/p>\n<p><strong>\u5173\u952e\u6307\u6807<\/strong>\uff1a<\/p>\n<ul>\n<li><strong>FOIT<\/strong>\uff08Flash of Invisible Text\uff09\uff1a\u5b57\u4f53\u52a0\u8f7d\u671f\u95f4\u6587\u672c\u4e0d\u53ef\u89c1\uff0c\u901a\u5e38\u7531 <code>font-display: block<\/code> \u5f15\u8d77\u3002<\/li>\n<li><strong>FOUT<\/strong>\uff08Flash of Unstyled Text\uff09\uff1a\u5148\u7528\u7cfb\u7edf\u5b57\u4f53\u663e\u793a\uff0c\u5b57\u4f53\u52a0\u8f7d\u540e\u66ff\u6362\uff0c\u53ef\u80fd\u5bfc\u81f4\u5e03\u5c40\u504f\u79fb\u3002<\/li>\n<li><strong>CLS<\/strong>\uff08Cumulative Layout Shift\uff09\uff1a\u5b57\u4f53\u66ff\u6362\u65f6\u5b57\u7b26\u5bbd\u5ea6\u53d8\u5316\u5bfc\u81f4\u7684\u5e03\u5c40\u79fb\u52a8\u3002<\/li>\n<\/ul>\n<h2>2. \u5b57\u4f53\u5b50\u96c6\u5316\uff1a\u53ea\u52a0\u8f7d\u7528\u5230\u7684\u5b57\u7b26<\/h2>\n<p>\u4e2d\u6587\u5b57\u4f53\u52a8\u8f84\u6570 MB\uff0c\u4f46\u9875\u9762\u53ef\u80fd\u53ea\u7528\u4e86 500 \u4e2a\u6c49\u5b57\u3002<strong>\u5b50\u96c6\u5316<\/strong>\u662f\u6700\u9ad8\u6548\u7684\u4f18\u5316\u624b\u6bb5\u3002<\/p>\n<h3>2.1 \u4f7f\u7528 <code>fontmin<\/code> \u8fdb\u884c\u5b50\u96c6\u5316<\/h3>\n<p>\u5b89\u88c5\uff1a<\/p>\n<pre><code class=\"language-bash\">\nnpm install fontmin --save-dev\n<\/code><\/pre>\n<p>\u521b\u5efa\u4e00\u4e2a Node.js \u811a\u672c <code>subset.js<\/code>\uff1a<\/p>\n<pre><code class=\"language-javascript\">\nconst Fontmin = require(&#x27;fontmin&#x27;);\nconst fs = require(&#x27;fs&#x27;);\n\n\/\/ \u63d0\u53d6\u9875\u9762\u4e2d\u7528\u5230\u7684\u6240\u6709\u5b57\u7b26\nconst text = fs.readFileSync(&#x27;.\/src\/index.html&#x27;, &#x27;utf8&#x27;);\nconst usedChars = Array.from(new Set(text.replace(\/\\s\/g, &#x27;&#x27;))).join(&#x27;&#x27;);\n\nconst fontmin = new Fontmin()\n  .src(&#x27;.\/fonts\/SourceHanSans-Regular.ttf&#x27;)\n  .use(Fontmin.glyph({\n    text: usedChars, \/\/ \u53ea\u4fdd\u7559\u8fd9\u4e9b\u5b57\u7b26\n    hinting: false   \/\/ \u79fb\u9664 hinting \u51cf\u5c0f\u4f53\u79ef\n  }))\n  .use(Fontmin.ttf2woff2()) \/\/ \u8f6c\u6362\u4e3a woff2 \u683c\u5f0f\n  .dest(&#x27;.\/dist\/fonts\/&#x27;);\n\nfontmin.run((err, files) =&gt; {\n  if (err) throw err;\n  console.log(&#x27;\u5b50\u96c6\u5316\u5b8c\u6210\uff0c\u751f\u6210\u6587\u4ef6\uff1a&#x27;, files.map(f =&gt; f.path));\n});\n<\/code><\/pre>\n<p>\u8fd0\u884c <code>node subset.js<\/code>\uff0c\u4f60\u4f1a\u5f97\u5230\u4e00\u4e2a\u53ea\u6709\u51e0\u5341 KB \u7684 <code>woff2<\/code> \u6587\u4ef6\u3002<\/p>\n<p>\ud83d\udca1 <strong>\u6ce8\u610f<\/strong>\uff1a\u5982\u679c\u9875\u9762\u5185\u5bb9\u662f\u52a8\u6001\u7684\uff08\u5982\u7528\u6237\u8bc4\u8bba\uff09\uff0c\u5b50\u96c6\u5316\u53ef\u80fd\u9057\u6f0f\u5b57\u7b26\u3002\u6b64\u65f6\u53ef\u4ee5\u4fdd\u7559\u4e00\u4e2a\u5b8c\u6574\u7684\u540e\u5907\u5b57\u4f53\uff0c\u6216\u4f7f\u7528 <code>unicode-range<\/code> \u5206\u7247\u52a0\u8f7d\u3002<\/p>\n<h3>2.2 \u4f7f\u7528 <code>unicode-range<\/code> \u6309\u9700\u5206\u7247<\/h3>\n<p>\u5bf9\u4e8e\u5927\u578b\u591a\u8bed\u8a00\u7ad9\u70b9\uff0c\u53ef\u4ee5\u5c06\u5b57\u4f53\u6309 Unicode \u8303\u56f4\u62c6\u5206\u4e3a\u591a\u4e2a\u6587\u4ef6\uff1a<\/p>\n<pre><code class=\"language-css\">\n@font-face {\n  font-family: &#x27;MyFont&#x27;;\n  src: url(&#x27;myfont-latin.woff2&#x27;) format(&#x27;woff2&#x27;);\n  unicode-range: U+0000-00FF, U+0131, U+0152-0153;\n  font-display: swap;\n}\n@font-face {\n  font-family: &#x27;MyFont&#x27;;\n  src: url(&#x27;myfont-chinese.woff2&#x27;) format(&#x27;woff2&#x27;);\n  unicode-range: U+4E00-9FFF;\n  font-display: swap;\n}\n<\/code><\/pre>\n<p>\u6d4f\u89c8\u5668\u53ea\u4f1a\u4e0b\u8f7d\u5f53\u524d\u9875\u9762\u5b9e\u9645\u7528\u5230\u7684\u5b57\u7b26\u6240\u5728\u7684\u5206\u7247\uff0c\u6781\u5927\u51cf\u5c11\u6d41\u91cf\u3002<\/p>\n<h2>3. \u9884\u52a0\u8f7d\u5173\u952e\u5b57\u4f53<\/h2>\n<p>\u5b57\u4f53\u901a\u5e38\u662f\u5728 CSS \u89e3\u6790\u540e\u624d\u53d1\u73b0\u5e76\u8bf7\u6c42\u7684\uff0c\u8fd9\u4f1a\u5bfc\u81f4\u5ef6\u8fdf\u3002\u4f7f\u7528 <code><link rel=\"preload\"><\/code> \u63d0\u524d\u89e6\u53d1\u4e0b\u8f7d\uff1a<\/p>\n<pre><code class=\"language-html\">\n&lt;link rel=&quot;preload&quot; href=&quot;\/fonts\/myfont-subset.woff2&quot; as=&quot;font&quot; type=&quot;font\/woff2&quot; crossorigin&gt;\n<\/code><\/pre>\n<p><strong>\u91cd\u8981<\/strong>\uff1a<code>crossorigin<\/code> \u5c5e\u6027\u5fc5\u987b\u52a0\uff0c\u5373\u4f7f\u5b57\u4f53\u540c\u6e90\u3002\u5426\u5219\u6d4f\u89c8\u5668\u4f1a\u53d1\u8d77\u4e24\u6b21\u8bf7\u6c42\u3002<\/p>\n<p>\ud83d\udca1 <strong>\u6ce8\u610f<\/strong>\uff1a\u53ea\u9884\u52a0\u8f7d\u9996\u5c4f\u5fc5\u9700\u7684\u5b57\u4f53\uff0c\u907f\u514d\u4e0e\u5173\u952e CSS\/JS \u4e89\u62a2\u5e26\u5bbd\u3002<\/p>\n<h2>4. \u9009\u62e9\u5408\u9002\u7684 <code>font-display<\/code> \u7b56\u7565<\/h2>\n<p><code>font-display<\/code> \u51b3\u5b9a\u5b57\u4f53\u52a0\u8f7d\u671f\u95f4\u6587\u672c\u7684\u663e\u793a\u65b9\u5f0f\uff1a<\/p>\n<p>| \u503c | \u884c\u4e3a | \u9002\u7528\u573a\u666f | |&#8212;-|&#8212;&#8212;|&#8212;&#8212;&#8212;-| | <code>auto<\/code> | \u6d4f\u89c8\u5668\u9ed8\u8ba4\uff08\u901a\u5e38\u7c7b\u4f3c block\uff09 | \u4e0d\u63a8\u8350 | | <code>block<\/code> | \u77ed\u6682\u4e0d\u53ef\u89c1\uff08\u7ea6 3s\uff09\uff0c\u7136\u540e\u56de\u9000 | \u56fe\u6807\u5b57\u4f53 | | <code>swap<\/code> | \u7acb\u5373\u7528\u56de\u9000\u5b57\u4f53\u663e\u793a\uff0c\u52a0\u8f7d\u540e\u66ff\u6362 | \u6b63\u6587\u6587\u672c | | <code>fallback<\/code> | \u6781\u77ed\u4e0d\u53ef\u89c1\uff08\u7ea6 100ms\uff09\uff0c\u7136\u540e\u56de\u9000 | \u5e73\u8861\u578b | | <code>optional<\/code> | \u6781\u77ed\u4e0d\u53ef\u89c1\uff0c\u82e5\u672a\u52a0\u8f7d\u5219\u4f7f\u7528\u56de\u9000\u4e14\u4e0d\u66ff\u6362 | \u6027\u80fd\u4f18\u5148 |<\/p>\n<p><strong>\u63a8\u8350<\/strong>\uff1a\u6b63\u6587\u4f7f\u7528 <code>swap<\/code>\uff0c\u6807\u9898\u4f7f\u7528 <code>optional<\/code> \u6216 <code>fallback<\/code>\u3002<\/p>\n<pre><code class=\"language-css\">\n@font-face {\n  font-family: &#x27;BodyFont&#x27;;\n  src: url(&#x27;body.woff2&#x27;) format(&#x27;woff2&#x27;);\n  font-display: swap;\n}\n<\/code><\/pre>\n<h2>5. \u6d88\u9664 CLS\uff1a\u4f7f\u7528 CSS \u5ea6\u91cf\u8986\u76d6<\/h2>\n<p>\u5373\u4f7f\u4f7f\u7528 <code>swap<\/code>\uff0c\u5b57\u4f53\u66ff\u6362\u65f6\u5b57\u7b26\u5bbd\u5ea6\u4e0d\u540c\u4ecd\u4f1a\u5bfc\u81f4\u5e03\u5c40\u504f\u79fb\u3002\u89e3\u51b3\u65b9\u6848\u662f\u8ba9\u56de\u9000\u5b57\u4f53\u7684\u5ea6\u91cf\u4e0e\u81ea\u5b9a\u4e49\u5b57\u4f53\u63a5\u8fd1\u3002<\/p>\n<h3>5.1 \u4f7f\u7528 <code>size-adjust<\/code> \u548c <code>ascent-override<\/code><\/h3>\n<pre><code class=\"language-css\">\n@font-face {\n  font-family: &#x27;BodyFont&#x27;;\n  src: url(&#x27;body.woff2&#x27;) format(&#x27;woff2&#x27;);\n  font-display: swap;\n  size-adjust: 105%; \/* \u8c03\u6574\u6574\u4f53\u5927\u5c0f *\/\n  ascent-override: 90%; \/* \u8c03\u6574\u4e0a\u4f38\u90e8 *\/\n  descent-override: 22%; \/* \u8c03\u6574\u4e0b\u4f38\u90e8 *\/\n  line-gap-override: 0%;\n}\n\n\/* \u56de\u9000\u5b57\u4f53\u5b9a\u4e49 *\/\n@font-face {\n  font-family: &#x27;BodyFont-Fallback&#x27;;\n  src: local(&#x27;Arial&#x27;);\n  size-adjust: 105%;\n  ascent-override: 90%;\n  descent-override: 22%;\n  line-gap-override: 0%;\n}\n\nbody {\n  font-family: &#x27;BodyFont&#x27;, &#x27;BodyFont-Fallback&#x27;, sans-serif;\n}\n<\/code><\/pre>\n<h3>5.2 \u81ea\u52a8\u751f\u6210\u5ea6\u91cf\u8986\u76d6<\/h3>\n<p>\u624b\u52a8\u8ba1\u7b97\u5f88\u9ebb\u70e6\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>fontaine<\/code> \u6216 <code>@capsizecss\/metrics<\/code> \u81ea\u52a8\u751f\u6210\u3002<\/p>\n<p>\u5b89\u88c5\uff1a<\/p>\n<pre><code class=\"language-bash\">\nnpm install @capsizecss\/metrics\n<\/code><\/pre>\n<p>\u793a\u4f8b\u811a\u672c\uff1a<\/p>\n<pre><code class=\"language-javascript\">\nconst { createFontStack } = require(&#x27;@capsizecss\/core&#x27;);\nconst { Roboto } = require(&#x27;@capsizecss\/metrics\/roboto&#x27;);\nconst { Arial } = require(&#x27;@capsizecss\/metrics\/arial&#x27;);\n\nconst { fontFamily, fontFaces } = createFontStack([Roboto, Arial]);\n\nconsole.log(fontFamily); \/\/ \u751f\u6210\u7684 font-family \u503c\nconsole.log(fontFaces);  \/\/ \u5bf9\u5e94\u7684 @font-face \u89c4\u5219\n<\/code><\/pre>\n<p>\u5c06\u751f\u6210\u7684 CSS \u63d2\u5165\u6837\u5f0f\u8868\u5373\u53ef\u3002<\/p>\n<h2>6. \u52a8\u6001\u5b57\u4f53\u6309\u9700\u52a0\u8f7d\uff08\u8fdb\u9636\uff09<\/h2>\n<p>\u5bf9\u4e8e\u7528\u6237\u751f\u6210\u5185\u5bb9\u6216\u5bcc\u6587\u672c\u7f16\u8f91\u5668\uff0c\u53ef\u4ee5\u76d1\u542c\u5b57\u4f53\u52a0\u8f7d\u4e8b\u4ef6\uff0c\u52a8\u6001\u8c03\u6574\uff1a<\/p>\n<pre><code class=\"language-javascript\">\ndocument.fonts.ready.then(() =&gt; {\n  console.log(&#x27;\u6240\u6709\u5b57\u4f53\u52a0\u8f7d\u5b8c\u6210&#x27;);\n  document.body.classList.add(&#x27;fonts-loaded&#x27;);\n});\n\n\/\/ \u6216\u8005\u76d1\u542c\u7279\u5b9a\u5b57\u4f53\ndocument.fonts.load(&#x27;1em BodyFont&#x27;).then(() =&gt; {\n  console.log(&#x27;BodyFont \u5df2\u52a0\u8f7d&#x27;);\n});\n<\/code><\/pre>\n<p>\u914d\u5408 CSS\uff1a<\/p>\n<pre><code class=\"language-css\">\nbody {\n  font-family: &#x27;BodyFont-Fallback&#x27;, sans-serif;\n}\n.fonts-loaded body {\n  font-family: &#x27;BodyFont&#x27;, &#x27;BodyFont-Fallback&#x27;, sans-serif;\n}\n<\/code><\/pre>\n<h2>7. \u5b8c\u6574\u793a\u4f8b\uff1a\u4f18\u5316\u4e00\u4e2a\u4e2d\u6587\u535a\u5ba2\u7684\u5b57\u4f53<\/h2>\n<p>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u4e2d\u6587\u535a\u5ba2\uff0c\u4f7f\u7528\u601d\u6e90\u9ed1\u4f53\u3002<\/p>\n<p><strong>\u6b65\u9aa4 1<\/strong>\uff1a\u63d0\u53d6\u9875\u9762\u7528\u5230\u7684\u5b57\u7b26\uff0c\u7528 <code>fontmin<\/code> \u5b50\u96c6\u5316\uff0c\u5f97\u5230 <code>sourcehan-subset.woff2<\/code>\uff08\u7ea6 80KB\uff09\u3002<\/p>\n<p><strong>\u6b65\u9aa4 2<\/strong>\uff1aHTML \u4e2d\u9884\u52a0\u8f7d\uff1a<\/p>\n<pre><code class=\"language-html\">\n&lt;link rel=&quot;preload&quot; href=&quot;\/fonts\/sourcehan-subset.woff2&quot; as=&quot;font&quot; type=&quot;font\/woff2&quot; crossorigin&gt;\n<\/code><\/pre>\n<p><strong>\u6b65\u9aa4 3<\/strong>\uff1aCSS \u5b9a\u4e49\uff1a<\/p>\n<pre><code class=\"language-css\">\n@font-face {\n  font-family: &#x27;SourceHan&#x27;;\n  src: url(&#x27;\/fonts\/sourcehan-subset.woff2&#x27;) format(&#x27;woff2&#x27;);\n  font-display: swap;\n  size-adjust: 100%;\n  ascent-override: 88%;\n  descent-override: 12%;\n  line-gap-override: 0%;\n}\n\n@font-face {\n  font-family: &#x27;SourceHan-Fallback&#x27;;\n  src: local(&#x27;PingFang SC&#x27;), local(&#x27;Microsoft YaHei&#x27;);\n  size-adjust: 100%;\n  ascent-override: 88%;\n  descent-override: 12%;\n  line-gap-override: 0%;\n}\n\nbody {\n  font-family: &#x27;SourceHan&#x27;, &#x27;SourceHan-Fallback&#x27;, sans-serif;\n}\n<\/code><\/pre>\n<p><strong>\u6b65\u9aa4 4<\/strong>\uff1a\u4f7f\u7528 Lighthouse \u9a8c\u8bc1 CLS \u4ece 0.25 \u964d\u81f3 0.02\u3002<\/p>\n<h2>8. \u5e38\u89c1\u5751\u4e0e\u6700\u4f73\u5b9e\u8df5<\/h2>\n<ul>\n<li><strong>\u5751 1<\/strong>\uff1a\u5fd8\u8bb0 <code>crossorigin<\/code> \u5bfc\u81f4\u91cd\u590d\u4e0b\u8f7d\u3002<\/li>\n<li><strong>\u5751 2<\/strong>\uff1a<code>font-display: block<\/code> \u5bfc\u81f4 FOIT \u65f6\u95f4\u8fc7\u957f\uff0c\u7528\u6237\u770b\u5230\u7a7a\u767d\u3002<\/li>\n<li><strong>\u5751 3<\/strong>\uff1a\u5b50\u96c6\u5316\u65f6\u672a\u5305\u542b\u6807\u70b9\u7b26\u53f7\uff0c\u5bfc\u81f4\u663e\u793a\u4e3a\u65b9\u6846\u3002<\/li>\n<li><strong>\u5751 4<\/strong>\uff1a\u4f7f\u7528 <code>local()<\/code> \u65f6\uff0c\u4e0d\u540c\u7cfb\u7edf\u5b57\u4f53\u5dee\u5f02\u5927\uff0c\u9700\u6d4b\u8bd5\u591a\u5e73\u53f0\u3002<\/li>\n<li><strong>\u6700\u4f73\u5b9e\u8df5<\/strong>\uff1a\u59cb\u7ec8\u63d0\u4f9b\u7cfb\u7edf\u5b57\u4f53\u56de\u9000\u6808\uff0c\u5e76\u786e\u4fdd\u56de\u9000\u5b57\u4f53\u4e0e\u81ea\u5b9a\u4e49\u5b57\u4f53\u5ea6\u91cf\u63a5\u8fd1\u3002<\/li>\n<li><strong>\u6700\u4f73\u5b9e\u8df5<\/strong>\uff1a\u4f7f\u7528 <code>font-display: swap<\/code> + \u9884\u52a0\u8f7d + \u5ea6\u91cf\u8986\u76d6\uff0c\u4e09\u8005\u7ed3\u5408\u6548\u679c\u6700\u4f73\u3002<\/li>\n<\/ul>\n<h2>\u603b\u7ed3<\/h2>\n<p>Web \u5b57\u4f53\u4f18\u5316\u4e0d\u662f\u5355\u4e00\u6280\u5de7\uff0c\u800c\u662f\u4e00\u5957\u7ec4\u5408\u7b56\u7565\uff1a<strong>\u5b50\u96c6\u5316\u51cf\u5c0f\u4f53\u79ef \u2192 \u9884\u52a0\u8f7d\u63d0\u524d\u8bf7\u6c42 \u2192 <code>font-display<\/code> \u63a7\u5236\u6e32\u67d3 \u2192 \u5ea6\u91cf\u8986\u76d6\u6d88\u9664 CLS<\/strong>\u3002\u6bcf\u4e00\u6b65\u90fd\u80fd\u5e26\u6765\u53ef\u91cf\u5316\u7684\u6027\u80fd\u63d0\u5347\u3002<\/p>\n<p>\u5efa\u8bae\u4f60\u4ece\u4eca\u5929\u5f00\u59cb\uff0c\u7528 Lighthouse \u5ba1\u8ba1\u81ea\u5df1\u7684\u7f51\u7ad9\uff0c\u6309\u7167\u672c\u6587\u6b65\u9aa4\u9010\u4e00\u4f18\u5316\u3002\u5b57\u4f53\u867d\u5c0f\uff0c\u5374\u76f4\u63a5\u5f71\u54cd\u7528\u6237\u4f53\u9a8c\u548c SEO \u6392\u540d\u3002<\/p>\n<p><strong>\u5ef6\u4f38\u9605\u8bfb<\/strong>\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/@font-face\/font-display\">MDN: font-display<\/a><\/li>\n<li><a href=\"https:\/\/web.dev\/optimize-webfont-loading\/\">web.dev: \u4f18\u5316 Web \u5b57\u4f53\u52a0\u8f7d<\/a><\/li>\n<li><a href=\"https:\/\/seek-oss.github.io\/capsize\/\">Capsize: \u5b57\u4f53\u5ea6\u91cf\u5de5\u5177<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u5b57\u4f53\u52a0\u8f7d\u4e0d\u5f53\u4f1a\u5bfc\u81f4\u9875\u9762\u95ea\u70c1\u3001\u5e03\u5c40\u504f\u79fb\uff0c\u4e25\u91cd\u5f71\u54cd\u7528\u6237\u4f53\u9a8c\u3002\u672c\u6587\u901a\u8fc7\u771f\u5b9e\u53ef\u8fd0\u884c\u7684\u4ee3\u7801\u793a\u4f8b\uff0c\u6559\u4f60\u5982\u4f55\u901a\u8fc7\u5b57\u4f53\u5b50\u96c6\u5316\u3001\u9884\u52a0\u8f7d\u3001font-display \u7b56\u7565\u548c CSS \u5ea6\u91cf\u8986\u76d6\uff0c\u5c06\u5b57\u4f53\u5bf9\u6027\u80fd\u7684\u5f71\u54cd\u964d\u5230\u6700\u4f4e\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[135,88,117,241,6],"class_list":["post-261","post","type-post","status-publish","format-standard","hentry","category-3","category-4","tag-cls","tag-css","tag-web","tag-241","tag-6"],"_links":{"self":[{"href":"https:\/\/yykcj.com\/index.php?rest_route=\/wp\/v2\/posts\/261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yykcj.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yykcj.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yykcj.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yykcj.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=261"}],"version-history":[{"count":0,"href":"https:\/\/yykcj.com\/index.php?rest_route=\/wp\/v2\/posts\/261\/revisions"}],"wp:attachment":[{"href":"https:\/\/yykcj.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yykcj.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yykcj.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}