Prerendering Testing Page

The purpose of this guide is to demonstrate how prerendering is managed in our CMP.
By default, consent is disclosed immediately, and all callbacks associated with the CMP are triggered, even on a prerendered page. To modify this behavior, you can enable the "Block consent during page prerendering" option in the PubConsent configurator. When this option is enabled, the CMP delays disclosing consent and executing callbacks while the page is in the prerendering phase. Instead, it waits until the page becomes visible to the user by listening for the prerenderingchange event before firing all proprietary and framework-dependent callbacks. An example of a function we wait to resolve before triggering all consent callbacks is:


function onPrerenderComplete(){
    return new Promise((resolve) => {
        if (document.prerendering) {
            document.addEventListener('prerenderingchange', () => resolve(), { once: true });
        } else {
            resolve();
        }
    });
}

Learn more about prerendering by visiting Google's prerendering documentation.

In this page, there is the following speculation rule:


<script type="speculationrules">
    {
      "prerender": [
        {
          "urls": ["prerendered.html","prerendered-gtm.html","not-blocking-prerendered.html"]
        }
      ]
    }
</script>

The following is an example of speculation-rules usage, which can be implemented on websites to enhance page load times by prerendering specific pages before user navigation.
The prerendered pages in this example are: prerendered.html, prerendered-gtm.html, and not-blocking-prerendered.html.
By default, consent is disclosed immediately, and all callbacks associated with the CMP are triggered, even on prerendered pages. However, in prerendered.html and prerendered-gtm.html, we have modified this behavior by enabling the "Block consent during page prerendering" option in the PubConsent configurator.
Conversely, in not-blocking-prerendered.html, consent is disclosed immediately (default behavior), and callbacks are executed right away, even if the page has not yet become visible to the user.

Learn more about speculation-rules by visiting Google's Speculation Rules.

To test the prerendered page please click the button you find below:

Go to the prerendered page (consent disclosure on open)! Go to the prerendered page with GTM integrated (consent disclosure on open)! Go to the prerendered page (immediate consent disclosure)!