In this document, we will discuss how to optimize website performance when using a cookie consent notice script. The goal is to compare website performance in four scenarios: without installing the consent notice, installing the consent notice immediately, installing the consent notice immediately with the "async" attribute, and installing the consent notice after a delay or after the user's mouse movement. We will analyze the performance implications of each of these scenarios.
In this scenario, the site does not have a cookie consent notice. Performance is maximized since no additional script is being executed.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Performance Test</title> <meta name="description" content="This is a performance test" /> </head> <body> Performance Test </body> </html>
In this scenario, the cookie consent notice is installed immediately upon page load. This can affect the site's performance.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Performance Test</title> <meta name="description" content="This is a performance test" /> <meta name="adopt-website-id" content="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" /> <script src="//tag.goadopt.io/injector.js?website_code=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" class="adopt-injector" ></script> </head> <body> Performance Test </body> </html>
In this scenario, the cookie consent notice is installed immediately upon page load with the 'async' attribute. This improves site performance as the script runs in parallel.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Performance Test</title> <meta name="description" content="This is a performance test" /> <meta name="adopt-website-id" content="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" /> <script async src="//tag.goadopt.io/injector.js?website_code=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" class="adopt-injector" ></script> </head> <body> Performance Test Async </body> </html>
In this scenario, the cookie consent notice is installed after a delay or in response to user mouse movement. This can enhance user experience and minimize the negative impact on performance by not loading large scripts immediately.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Performance Test</title> <meta name="description" content="This is a performance test" /> <meta name="adopt-website-id" content="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" /> <script> var scriptLoaded = false; function loadScript() { if (!scriptLoaded) { var script = document.createElement("script"); script.src = "//tag.goadopt.io/injector.js?website_code=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; script.classList.add("adopt-injector"); document.head.appendChild(script); scriptLoaded = true; } } setTimeout(loadScript, 4000); document.addEventListener("mousemove", function () { loadScript(); document.removeEventListener("mousemove", loadScriptOnMouseMovement); }); </script> </head> <body> Performance Test </body> </html>
Here are some conclusions based on the comparison of the four scenarios:
Scenario 1: Without the consent notice, performance is the best, but it may not comply with data privacy regulations.
Scenario 2: Immediate installation of the consent notice may negatively impact site performance. Since this is a matter of milliseconds, this performance change can affect search engine systems and reduce the site's ranking, without impacting user experience significantly.
Scenario 3: Installing the consent notice with the "async" attribute slightly improves performance compared to the previous scenario. However, it may still cause ranking issues in search engine systems.
Scenario 4: Installing the consent notice after a delay or in response to mouse movement can balance data privacy compliance and site performance. However, user experience might be affected if the delay is too long.
This document aims to provide an overview of the performance implications when using a cookie consent notice and offer guidance on how to optimize site performance. The choice of the appropriate scenario will depend on the specific needs and priorities of your site and audience.
AdOpt
Resources
Legal Terms
© GO ADOPT, LLC since 2020 • Made by people who love
🍪