We have identified that our cookie-script banner is currently experiencing excessively long Interaction to Next Paint (INP) times, which significantly affects user experience and SEO performance.
The INP metric is a critical performance indicator that measures the delay between user interactions and the subsequent visual response. Long INP times can lead to user frustration, higher bounce rates, and ultimately, a negative perception of our website's quality. In addition, this can also lower SEO performance, as the INP metric is one of Core Web Vitals used by Google as a ranking factor.
The simplest way, especially during simple rejection or acceptance of cookies, would be to allow the banner to close before running resource-intensive JS work. This could be achieved by using a zero-time
setTimeout
(https://web.dev/articles/optimize-inp?hl=en#yield_to_the_main_thread_often). By deferring the execution of non-critical scripts until after the banner has been closed, we can ensure that the interaction is smooth and immediate.