How to improve Core Web Vitals in TYPO3
What can designers, developers, and admins of a TYPO3 site do to make the Core Web Vitals skyrocket? Here are some tips and quick wins.
TYPO3 features that help with optimizing Core Web Vitals
TYPO3 comes with handy built-in features that can help rank better in these metrics: caching, support for lazy loading, and asynchronous JavaScript loading.
Caching
Optimal caching is a great step towards high Core Web Vitals scores. TYPO3 has several caching strategies and chooses the best one based on the use case (static, semi-static, or dynamic pages), but the simple rule is that the more cache-friendly your page design is, the better the pages can rank.
Lazy image loading
Particular element types, first and foremost images, can be lazy-loaded after the main content has been rendered. TYPO3 supports lazy loading of images by default for all Fluid-styled content. If you use custom Fluid templates, make sure that your templates use the ‘loading’ attribute like so:
<f:image src="{file.uid}" treatIdAsReference="1" loading="{settings.media.lazyLoading}" />
Automatic image optimization
Image size can significantly affect page load performance. Images added to a page unmodified are often too large and compressed with a low compression ratio. Extensions like b13/picture turn images into the format you need.
Often neglected: cleaning up unused code
Every web project risks accumulating scripts and CSS configurations that aren’t used anymore. Still, the web server delivers those artifacts to the browsers, where they drag down the performance metrics. Tools like PageSpeed Insights indicate if there is old, unused code to get rid of.
How to monitor Core Web Vitals and overall site performance
Before you can start optimizing your site, you need to collect Core Web Vital metrics first. Luckily, tools like Lighthouse are built into the browser’s console (for Chromium-based browsers) or available as an extension, so you can start measuring right away. And after having optimized your code, you’ll likely want to run regular measurements to ensure the metrics don’t deteriorate.
If you have suboptimal Core Web Vitals measurements but are unsure where to start looking for the culprits, consider running a general performance test with Blackfire to pinpoint the performance bottlenecks at the PHP level. From there, you can work your way through fixing the slowest parts until the desired performance is achieved.