Optimizing your largest contentful paint (LCP) can be hard
Here are 8 tips, with code snippets and visuals, to help your pages load fast for optimal SEO and UX
🧵👇
First, how is LCP measured?
> The Largest Contentful Paint (LCP) metric reports the render time of the largest image or text block visible within the viewport, relative to when the page first started loading
As much as possible, serve all pages and content pregenerated from a CDN cache. This ensures that response times are fast, and content can be visible as quickly as possible
Importantly - be sure to optimize and prioritize your images. Use nextgen formats, optimal sizing, and eager prioritize your LCP image and lazy load others:
Similarly, as much as possible, remove blocking externally fetched CSS
CSS-in-JS libraries like styled-components or emotion can help a lot with this, or tools that can extract and inline critical CSS web.dev/extract-critic…
JS execution time can really hurt your LCP time as well. Be sure to optimize your site or app to require as little JS as possible to boot up.
Then, no site is complete without ways of managing and optimizing content. As much as possible, prefer API driven services for best performance, as opposed to those that require in-browser JS
Want to measure your LCP and see which tip above might help improve it the most?
Oh ya! And don't forget to measure measure measure your site speed. Prefer tools that emulate real world devices like @RealWebPageTest and Google Pagespeed Insights over running Lighthouse in your desktop browser that may not match typical real world device specs
In all seriousness though, I know I post a lot of coding tips and "do this not that" best practices stuff, but I want to use this as a reminder to point out...
I don't write perfect code. No one does. My code has been complained about by fellow engineers as much as anyone, if not probably more.
Civet (@civetlang) is a new alternative syntax for TypeScript
Init flame war about syntax preferences:
Regardless of the syntax you prefer, the point of Civet is you can choose
You can write normal TSX opting into just a modern feature or two, or use a completely ruby/python style, or something in between similar to rust
Personally, I like the ability to bring more functional programming patterns to TSX, in an easy to incrementally opt-in way
I love TS, but there are some features of other languages that I miss, and I am intrigued by Civet's ability to potentially strike a balance for modern TS