How to improve lighthouse scores

October 25, 2024

One of the best ways you can cater to the user is by making sure your pages load quickly, so how can you do that?

How did I do it?

Performance

In order to score highly on google lighthouse first you must understand that their performance score is a little misleading. Your goal should be to aim highly, not perfectly.

The reason is because performance is partially down to the machine running the test. Of course you can make your website plain HTML and hit 100 on an old laptop, but we all want some fancy effects dont we? So score highly, not perfectly here.

Accessibility

Accessibility is about ensuring anyone, regardless of abilities, can use your site. Start with semantic HTML—use header, main, and footer tags and make sure interactive elements, like buttons or links, have clear, descriptive labels. A lot of accessibility issues come down to small oversights, like missing alt tags on images or low-contrast text, so a quick check can often catch these. Aim to make the experience seamless for everyone; it’ll not only improve your Lighthouse score but also create a more inclusive experience for your visitors.

Best Practices

Best practices cover things like HTTPS usage, security headers, and handling requests efficiently. A few things to look out for:

Use HTTPS: This is non-negotiable for security and user trust.

  • Avoid unused code: Tree-shake or code-split where possible.
  • Optimize third-party scripts: Too many can slow you down, so only include what you truly need.
  • These small steps go a long way in keeping your site both lightweight and secure.

SEO

SEO isn’t just about keywords; it's also about structure. Make sure your title, meta description, and heading tags (h1, h2, etc.) reflect your content accurately. Use descriptive, concise URLs and always include alt tags for images. Google loves clarity and relevance, so aim for both.

Wrapping Up

Improving Lighthouse scores isn't just about numbers—it's about creating a site that’s quick, accessible, and user-friendly. Try to find a balance that makes sense for your project. At the end of the day, a high score is great, but a high-quality user experience is even better.