Prerendering & CMP: Enhancing Consent Handling and Performance
In this guide, we want to introduce you to a feature that can significantly enhance your website's user experience: prerendering!
Prerendering is a technology used by the Chrome browser to load and prepare certain web pages in advance, making them instantly available when the user decides to visit them. This reduces wait times and ensures a smoother and faster interaction with the site.
For more details on this feature, refer to the official Chrome documentation.
One of the questions we at Pubtech have asked ourselves is:
What should happen during prerendering? Should consent be disclosed to scripts immediately, or should it wait until the page is actually viewed by the user?
By default, our CMP immediately discloses user consent and triggers all associated callbacks, even if the page is still in the prerendering phase.
However, you can customize this behavior by enabling the "Block consent during page prerendering" option in the PubConsent configurator. When this option is enabled, the CMP delays consent disclosure and callback execution until the page becomes visible to the user. This is achieved by monitoring the prerenderingchange event, preventing scripts or trackers from activating prematurely.
By enabling this feature, you can:
- Prevent premature callback execution, ensuring more reliable consent management.
- Improve data quality, as trackers will only activate when the user actually interacts with the page.
- Optimize site performance, avoiding unnecessary resource loading before the page is fully visible.
Beyond consent management, prerendering can be leveraged to enhance overall website performance. A prime example is in the advertising sector: by utilizing the prerendering phase to prepare all necessary elements in advance, you can reduce load times and significantly improve the user experience. By carefully monitoring the process and implementing the right strategies, you can maximize your website’s performance and optimize the effectiveness of your advertising campaigns.
We recommend that you explore and make use of the features outlined in the official Chrome documentation. Using prerendering, combined with intelligent consent management, allows you to optimize both website performance and privacy compliance, creating a perfect balance between efficiency and respect for user choices.
With the new PubConsent feature, you now have full control over what happens during prerendering, allowing you to more comprehensively customize the management of user consent!