Improving LCP on TIL News Sites: An In-depth Look at our Optimization Methods
Authored By: Daya Ram Yadav, Fanendra Nath Tripathi, Neeraj Upadhyay, Niraj Tiwari
This blog builds on our previous discussion about optimizing Core Web Vitals for TIL News sites, where we explored broad strategies to enhance key metrics like LCP, FID, and CLS. In this follow-up, we’re taking a deep dive into Largest Contentful Paint (LCP)- a pivotal performance metric for page load speed. We’ll share practical strategies, real-world implementations, and measurable outcomes to showcase how we’ve significantly improved LCP across our platforms, ensuring a faster, more engaging experience for our users.
Introduction to Largest Contentful Paint(LCP)
Largest Contentful Paint (LCP) is a key metric that measures how quickly the largest visible element on a webpage- be it an image, video, or text block- renders. As part of Google’s Core Web Vitals, LCP directly influences user experience and site performance.
In today’s fast-paced digital world, users expect near-instant page load speeds. A poor LCP score can lead to higher bounce rates, while a fast LCP fosters better engagement and retention. This metric emphasizes the loading speed of the most critical content that users first interact with, shaping their perception of the site’s responsiveness.
By focusing on improving LCP, you not only boost user satisfaction but also align your site with Google’s search ranking criteria, giving it an edge in visibility and performance.
Key Metrics that Define Largest Contentful Paint (LCP)
Understanding what shapes and influences LCP is crucial for optimizing your website's performance. Let’s break it down into measurable components:
1. Measurement Time: LCP is calculated from the moment a user begins? loading a page to the point when the largest visible content element is fully rendered in the viewport.
2. Content Elements: LCP focuses on the largest visual elements on the page, including:
3. Performance Thresholds: Google uses these thresholds to evaluate LCP performance:
4. Impact Factors: Several factors directly influence LCP performance:
Optimizing these factors is essential to deliver a seamless and engaging user experience.?
Our Optimization Techniques:???????
1. Improving Server Response Time
Improving server response time is critical for optimizing LCP and overall user experience. To achieve this, we implemented several strategies, including server-to-server API calls over a private network, pre-rendering pages, and leveraging caching on a Content Delivery Network (CDN). Below is a? breakdown of these initiatives and their impact on performance.
A. Server-to-Server API Calls on a Private Network
By transitioning our API calls from the public internet to a private network, we minimized latency and improved response times significantly.
B. Pre-rendering Pages
Pre-rendering involves generating HTML content in advance and serving it when requested, eliminating real-time processing for frequently accessed pages.
C. Caching on a Content Delivery Network (CDN)
Utilizing a CDN to cache static assets and pre-rendered pages further optimized our response times.
2. Moving Javascripts from the <head> tag (Impact - High)
One of the key strategies implemented to improve LCP was moving all scripts and JSON schema to load after the main App HTML. This change prioritized the parsing of critical page content by ensuring that the main HTML structure loaded first. High-priority JavaScript files, such as ad-related scripts, were preloaded in the head tag to mitigate any delays caused by repositioning scripts.
We conducted two studies to assess the impact. The following section detail the experiments and their results:
A. Case Study 1: Videoshow Page Implementation
On August 20, 2024, we made an implementation on the TOI Videoshow Page, impacting around 62K URLs in the 'Needs Improvement' state for LCP. Following the changes, this number dropped to just 40 URLs in the same category, indicating a significant improvement in LCP performance.
B. Case Study 2: Site-wide Videoshow Improvements
On August 29, 2024, a site-wide update was rolled out, addressing various subsections of the Videoshow page. This update resulted in significant improvements in LCP, which were evident in Google Search Console (GSC) reports, reflecting better load times and overall performance.
3. Inline Critical CSS (Impact - High)
External CSS files can introduce delays in rendering, which in turn can slow down the loading of the main image on the page.. To speed this up, we added important CSS directly in the page's head section, allowing key content to load faster. Non-essential CSS was either deferred to load later, from external files placed at the bottom of the page or included within the page itself.
4. Optimized Largest Contentful Paint (LCP) images (Impact - High)
We implemented next-gen image formats with advanced compression that significantly reduce file sizes without compromising quality and adapt delivery based on the client’s network speed.?
5. Preloading LCP Key assets and Lazy Loading Other Images (Impact - High)
To optimize initial page load times, we preloaded the LCP image in the head tag with a high fetch-priority. We also removed non-critical preload, pre-connect, and prefetch tags from the head section. Deferred loading was applied to images below the fold, optimizing initial page load time by minimizing data transfer.
<link rel="preload" as="image" href="lcp-image.jpg" />
<img src="lcp-image.jpg" fetchpriority="high">
领英推荐
6. Enabling HTTP/3 (Impact - Medium)
We successfully implemented HTTP/3, which has led to substantial improvement in connection? speed, reliability, and overall user experience.
In the below metrics, you can observe that the LCP on HTTP/3 is around 766ms compared to 1.13s on HTTP/2, showcasing the noticeable performance boost.
7. Enabled Brotli Compression (Impact - High)
On average, Brotli compression reduces JavaScript files by 14%, HTML files by 21%, and CSS files by 17% compared to gzip. By applying Brotli compression to these resources, we achieved an overall? 14% reduction in chunk size.
8. Reduced Page HTML size (Impact - Medium)
To enhance initial load times, we implemented lazy loading for non-SEO critical components, ensuring only essential elements loaded first. By streamlining HTML structure, we reduced excess tags and minimized nesting, leading to faster parsing and a lighter markup. Additionally, we purged unused CSS from critical paths, allowing only necessary styles to be loaded upfront. The state JSON was moved to an external file, reducing the initial payload size.
A. Moved out State JSON from initial HTML
B. AMP Page (Accelerated Mobile Pages) Optimizations?
After updating the code on the article pages? and homepage for AMP (Accelerated Mobile Pages):
2. Javascript Optimization: Initially, these JavaScript files were included in the code. We removed them, streamlined some features, and applied conditional hide/show logic wherever necessary.
9. Removed Custom Fonts (Impact - Low)
We replaced custom fonts such as Montserrat with system fonts like Verdana, arial and sans-serif. This change eliminated about 120KB of font files and 4 network requests, which reduced font loading and parsing time.
10. Reduced Javascript Size (Impact - High)
By reducing the size of JavaScript files, we achieved several performance improvements:?
A. Faster Download and Execution: Smaller JavaScript download quicker, allowing the browser to execute scripts faster? and render key elements including LCP, more promptly.
B. Less Render Blocking: Optimizing JavaScript minimized blocking on the main thread, enabling the browser to prioritize rendering LCP elements without delay.
C. Improved Resource Efficiency: With smaller scripts, the browser used fewer resources (memory and processing power), helping to speed up content display and positively impact LCP.
Browser Screenshots:
Key Takeaways
The comprehensive strategies implemented to enhance Largest Contentful Paint (LCP) across TIL News sites yielded significant improvements. High-impact changes, such as optimizing server response times, streamlining critical CSS delivery, and compressing resources, had the most immediate and substantial effects on LCP. These optimizations were complemented by medium and low-impact changes, which further contributed to performance gains and an overall enhanced user experience. By adopting a structured and comprehensive approach to addressing LCP, we achieved meaningful reductions in loading times and improved user satisfaction.
Key techniques like implementing server-to-server API calls over private networks, pre-rendering content, and leveraging a Content Delivery Network (CDN) collectively expedited server response times. This resulted in faster delivery of essential content to users, leading to a marked improvement in LCP and increased user engagement.
Inlining critical CSS and adopting Brotli compression streamlined resource loading by reducing page size and HTTP requests. These enhancements, coupled with a leaner HTML structure and lazy loading of non-critical elements, allowed the browser to prioritize and render key content efficiently, improving both perceived and actual load times.
The adoption of HTTP/3 further accelerated LCP improvements by enabling faster connections and optimizing resource loading, especially under challenging network conditions. This, along with systematic reductions in JavaScript and font-related overheads, ensured that users experienced a smoother and faster browsing journey.
Takeaway: A holistic, data-driven approach to LCP optimization- prioritizing high-impact changes while addressing smaller bottlenecks- creates tangible performance gains. These efforts not only enhance LCP metrics but also elevate user satisfaction, engagement, and retention, making them indispensable for delivering a superior digital experience.
We strive to deliver the best experience to our readers, continually experimenting and innovating to enhance performance. Keep an eye on our blogs to stay updated on the strides we’re making and what’s coming next!
Join Us And #TakeUsToTheNextLevel: https://timesinternet.in/careers
Credits:
Ashish Jaiswal, Puneet Kukreja, Barun Kumar, Hunny Chawla, Ujjwal Paul, Md Rahber Azam, Virendra Rastogi, Vaibhav Sharma, Aditya Singh, Manoj Patial, Paras Agarwal
References:
Senior Technical Consultant (Ex-Times Internet, Ex-Dainik Jagran) PHP | MEAN | MERN | Cloud Services - AWS & Azure | DevOps | SaaS | Microservices | Project Management
3 个月Very useful post. Congratulations to all authors.
Technical Architect at Times Internet - ET
3 个月Insightful
Delhi University
3 个月Largest contentful paint is a useful tool for web developers to built a vibrant website using artificial intelligence tools which is also helpful in the development of powerful websites and that brings much more revenue to the corporates which ultimately enhance gross domestic product and national income of one nation.