pressidium / pressidium-cookie-consent

🍪 Lightweight, user-friendly and customizable cookie consent banner to help you comply with the EU GDPR cookie law and CCPA regulations.
https://wordpress.org/plugins/pressidium-cookie-consent/
GNU General Public License v2.0
52 stars 4 forks source link

Small Issue with PageSpeed Insights #68

Closed WebsCat closed 3 months ago

WebsCat commented 6 months ago

First of all, thank you very much for developing the plugin, I find it very good.

In the Google Chrome console, I get an error: Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')

When I look at the code, it is in a function: <script> document.getElementById('cookieConsentButton').addEventListener('click', function() { //window.pressidiumCookieConsent.show(); pressidiumCookieConsent.showSettings(); }); </script>

This small issue affects the PageSpeed Insights results as it reduces the "Best Practices" score by 4 points.

Would it be possible to fix this issue?

Thank you!

Sorry, it's my mistake. I tried it on another website without any cache plugin and there is no problem. I will have to review the W3 Total Cache settings.

WebsCat commented 6 months ago

Sorry, it's my mistake. I tried it on another website without any cache plugin and there is no problem. I will have to review the W3 Total Cache settings.

Maybe the error could be handled with if (cookieConsentButton) {

over-engineer commented 3 months ago

Hey, @WebsCat!

Thank you for your kind words and for mentioning that. I’ll look into adding an if (pressidiumCookieConsent) condition in a future version of the plugin.

I’m glad everything was resolved.

I’m closing this issue. If you have any more questions, feel free to ask 🙂