N
Nuxt7mo ago
grip

Third-party script hydration mismatch

Hey, I have a third-party script for my CMP which modifies part of the <body> to add the elements required to show the cookie banner. The script is loaded with async and defer. When these elements are added, I get a hydration error. Using the app:mounted hook or some fixed timeout to show the banner is a solution but then i get a hit in LCP. Any recommendations on how to approach this? thanks!
3 Replies
harlan
harlan7mo ago
Chrome for Developers
Lazy load third-party resources with facades  |  Lighthouse  |  Chr...
Learn about the opportunities to lazy load third-party resources with facades.
harlan
harlan7mo ago
basically you render a "fake" cookie consent banner that gets replaced with the real thing once it's hydrated it's not ideal though, you'd probably be better off implementing the CMP yourself if you want to avoid performance penalties
grip
gripOP7mo ago
i managed to do something like this in the end yeah, thanks!
Want results from more Discord servers?
Add your server