<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Cengizhnx</title>
    <description>The latest articles on DEV Community by Cengizhnx (@cengizhnx).</description>
    <link>https://dev.to/cengizhnx</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4282844%2Fc6435661-be61-4f11-b7c0-0ea8c5ce37cf.png</url>
      <title>DEV Community: Cengizhnx</title>
      <link>https://dev.to/cengizhnx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cengizhnx"/>
    <language>en</language>
    <item>
      <title>What Moved My Lighthouse Scores: 5 Fixes on an Astro Site</title>
      <dc:creator>Cengizhnx</dc:creator>
      <pubDate>Fri, 04 Dec 2026 13:11:59 +0000</pubDate>
      <link>https://dev.to/cengizhnx/what-moved-my-lighthouse-scores-5-fixes-on-an-astro-site-8he</link>
      <guid>https://dev.to/cengizhnx/what-moved-my-lighthouse-scores-5-fixes-on-an-astro-site-8he</guid>
      <description>&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; on a static Astro site the framework gets you most of the way, and the last points come from small, specific decisions: which CSS blocks rendering, what JavaScript runs while the page is still loading, which font weight the text actually uses, and whether any image is being stretched. Here are the five changes that measurably moved the numbers on this site, with the measurements.&lt;/p&gt;

&lt;p&gt;This site is built with Astro (static output) and Tailwind CSS v4, served from Cloudflare. It is a bilingual portfolio with a blog, a lot of animation on the home page, and almost no JavaScript elsewhere.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I measured
&lt;/h2&gt;

&lt;p&gt;Every number below is from &lt;strong&gt;Lighthouse in mobile mode, against a production build&lt;/strong&gt; (&lt;code&gt;astro build&lt;/code&gt;, served by the same server as the live site), never the dev server. Lab results vary from run to run, sometimes by 5 points and 150 ms of Total Blocking Time on the same page, so I ran each test several times and compare the runs, not a single score.&lt;/p&gt;

&lt;p&gt;Lab scores are a debugging tool. What Google uses for ranking is field data from real visitors (Core Web Vitals over the last 28 days), so the goal is not a perfect 100 but no regressions you can measure.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Inline the CSS
&lt;/h2&gt;

&lt;p&gt;The whole site compiles to about 9 KB of CSS after compression. As a separate file it was the only render-blocking request on every page: the browser had to fetch it before it could paint anything.&lt;/p&gt;

&lt;p&gt;Astro can put the stylesheet straight into the HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// astro.config.mjs&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;inlineStylesheets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"always"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; LCP improved by 0.3–0.5 s on mobile.&lt;/p&gt;

&lt;p&gt;This only pays off when the CSS is small. Inlined CSS is downloaded again with every page instead of being cached, so for a large stylesheet the separate, cached file is usually the better trade. Measure both.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Turn the loader off where people come to read
&lt;/h2&gt;

&lt;p&gt;The site has an intro loader: “Software Developer” decodes out of code glyphs while the statue resolves from an ASCII version of itself. It shows on a first visit and on a reload.&lt;/p&gt;

&lt;p&gt;On the home page that is fine. On a blog post it was not. The loader rewrites its text on every frame, and on a page with a long article each of those updates made the browser recalculate the layout of the whole document. Total Blocking Time on a post was &lt;strong&gt;450–480 ms&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Two changes fixed it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No loader on posts.&lt;/strong&gt; Readers arrive from search for the text, not for an intro. The layout takes a &lt;code&gt;preloader={false}&lt;/code&gt; prop, and the inline script that decides whether to show the loader skips it when the page opts out.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use the font weight that is already preloaded.&lt;/strong&gt; The body text of a post was set in weight 300, which is not one of the two weights the site preloads. It arrived late and the whole article was laid out a second time. Setting the text to the preloaded weight 400 removed that second layout, and it also reads better at length.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn2w5j9y08d7rb7nnk8d4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn2w5j9y08d7rb7nnk8d4.png" alt="Bar chart of Total Blocking Time on a long blog post across three stages: with the loader 450 and 480 ms; loader off 400, 320 and 190 ms; with the preloaded font weight 230, 110 and 120 ms." width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; TBT fell to &lt;strong&gt;110–230 ms&lt;/strong&gt; across runs, and the performance score went from &lt;strong&gt;86&lt;/strong&gt; to &lt;strong&gt;95–98&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Make the fallback font match the web font
&lt;/h2&gt;

&lt;p&gt;Fonts are self-hosted WOFF2 files, subset to Latin and Latin Extended (the site has a Turkish version, so ğ, ş, ı and İ have to stay). Only the two weights used above the fold are preloaded, and &lt;code&gt;font-display: swap&lt;/code&gt; shows text immediately.&lt;/p&gt;

&lt;p&gt;Swapping can still shift the layout when the web font arrives, because the fallback font has different metrics. A metric-matched fallback fixes that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@font-face&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Poppins Fallback"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;src&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;local&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Arial"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;ascent-override&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;93.62&lt;/span&gt;&lt;span class="kt"&gt;%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;descent-override&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;31.21&lt;/span&gt;&lt;span class="kt"&gt;%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;line-gap-override&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;8.92&lt;/span&gt;&lt;span class="kt"&gt;%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;size-adjust&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;112.16&lt;/span&gt;&lt;span class="kt"&gt;%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The page then uses &lt;code&gt;font-family: "Poppins", "Poppins Fallback", sans-serif&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; Cumulative Layout Shift stays between 0.001 and 0.017 on the pages I measured, far below the 0.1 “good” threshold.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Do not let the browser upscale an image
&lt;/h2&gt;

&lt;p&gt;Best Practices was stuck at &lt;strong&gt;96&lt;/strong&gt; on every page, with one warning: “Serves images with low resolution”. The culprit was not a content image but a faint, decorative statue in the background of the menu. Its source was 448 px wide, and the menu displays it at up to 82% of the screen height, so the browser was stretching it.&lt;/p&gt;

&lt;p&gt;The fix was a 2× version of that image (an upscale of the original; at the menu’s low opacity and in greyscale the softness does not show), with &lt;code&gt;widths={[448, 672, 896]}&lt;/code&gt; so the browser picks the right size.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; Best Practices &lt;strong&gt;96 → 100&lt;/strong&gt; on every page. When a warning appears on every page, look at the shared layout first: menus, headers and footers.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Watch what you ship that nobody sees
&lt;/h2&gt;

&lt;p&gt;Two things on this site cost bytes without being visible:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Share images.&lt;/strong&gt; Each post gets a 1200×630 share image generated at build time with satori. I first exported them as PNG, which is lossless and very large for artwork. Switching to JPEG took them from about &lt;strong&gt;1.1 MB to about 100 KB&lt;/strong&gt; each. Lighthouse does not test them, but every link preview on LinkedIn or WhatsApp downloads one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HTML comments.&lt;/strong&gt; Astro keeps &lt;code&gt;&amp;lt;!-- --&amp;gt;&lt;/code&gt; comments from templates in the output. My code comments were adding about &lt;strong&gt;2.3 KB&lt;/strong&gt; to every page, and an AI-visibility checker I ran read them as the start of the page text. Writing them as &lt;code&gt;{/* */}&lt;/code&gt; instead keeps them in the source only.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9dmqvvgtm5vwyxjqbx49.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9dmqvvgtm5vwyxjqbx49.png" alt="Bar chart of share image size per post: 1136 KB as PNG versus 106 KB as JPEG, 1235 versus 104 KB, and 732 versus 67 KB." width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What the validator caught
&lt;/h2&gt;

&lt;p&gt;Not Lighthouse, but worth running next to it: &lt;a href="https://html-validate.org/" rel="noopener noreferrer"&gt;html-validate&lt;/a&gt; on the built pages found three things Lighthouse did not.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Inline styles from syntax highlighting.&lt;/strong&gt; Astro’s default highlighter writes a &lt;code&gt;style&lt;/code&gt; attribute on every token. The code samples on this blog are short, so I turned highlighting off (&lt;code&gt;markdown.syntaxHighlight: false&lt;/code&gt;) and styled code blocks with the site’s CSS.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Heading ids with non-ASCII characters.&lt;/strong&gt; Markdown heading ids kept Turkish letters, and the capital &lt;code&gt;İ&lt;/code&gt; became a lowercase &lt;code&gt;i&lt;/code&gt; plus a combining dot, which is not a valid id character. A small plugin now transliterates headings to ASCII slugs, and the table of contents uses the same function.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A stale Markdown cache.&lt;/strong&gt; After changing the Markdown settings, built pages still had the old heading ids: Astro caches rendered Markdown in &lt;code&gt;node_modules/.astro/data-store.json&lt;/code&gt;, and build caches can restore &lt;code&gt;node_modules&lt;/code&gt;. A &lt;code&gt;prebuild&lt;/code&gt; script now deletes that file.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;p&gt;&lt;/p&gt;
  Is a Lighthouse score of 100 worth chasing?
  &lt;br&gt;
Not as a goal on its own. Google ranks with field data from real visitors, and lab scores vary between runs. Fix what the report points to, check that LCP, CLS and INP are in the good range for real users, and stop when the changes no longer move the field data.&lt;br&gt;


&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
  Should I always inline CSS in Astro?
  &lt;br&gt;
Only when it is small. Inlining removes a render-blocking request but the CSS is downloaded with every page instead of being cached. For a few kilobytes that is a good trade; for a large stylesheet, measure before switching.&lt;br&gt;


&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
  Why did removing a loader improve Total Blocking Time so much?
  &lt;br&gt;
Because of what it touched, not how much JavaScript it was. It changed text on every frame while the page was still loading, and on a long page each change made the browser recalculate the layout of the whole document.&lt;br&gt;


&lt;p&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;None of these changes is large. What they have in common is that I found each one by measuring the production build several times, looking at what the report actually blamed, and fixing that thing rather than following a generic checklist.&lt;/p&gt;

&lt;p&gt;If you want a second pair of eyes on a slow site, &lt;a href="https://cengizhnx.dev/#contact" rel="noopener noreferrer"&gt;get in touch&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Astro: &lt;a href="https://docs.astro.build/en/reference/configuration-reference/#buildinlinestylesheets" rel="noopener noreferrer"&gt;Configuration reference: build.inlineStylesheets&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;web.dev: &lt;a href="https://web.dev/articles/lcp" rel="noopener noreferrer"&gt;Largest Contentful Paint&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;web.dev: &lt;a href="https://web.dev/articles/tbt" rel="noopener noreferrer"&gt;Total Blocking Time&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;web.dev: &lt;a href="https://developer.chrome.com/blog/font-fallbacks" rel="noopener noreferrer"&gt;Improved font fallbacks&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Chrome for Developers: &lt;a href="https://developer.chrome.com/docs/lighthouse/best-practices/image-size-responsive" rel="noopener noreferrer"&gt;Lighthouse: serve images with appropriate resolution&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/vercel/satori" rel="noopener noreferrer"&gt;satori&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://html-validate.org/" rel="noopener noreferrer"&gt;html-validate&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://cengizhnx.dev/blog/astro-lighthouse-fixes/" rel="noopener noreferrer"&gt;cengizhnx.dev&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>astro</category>
      <category>webperf</category>
      <category>lighthouse</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
