Title: EU Cookie Law &#8211; Script error
Last modified: July 22, 2020

---

# EU Cookie Law – Script error

 *  Resolved [darknessfx](https://wordpress.org/support/users/darknessfx/)
 * (@darknessfx)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/ue-cooki/)
 * Problem:
    If you set Capture consent & hide the banner to 30 seconds, if the 
   user already had the cookie the script throw an error.
 * Error:
    Uncaught TypeError: Cannot read property ‘removeChild’ of null at eu-
   cookie-law.min.js?ver=20180522:2
 * Script:
    function(){n.parentNode.removeChild(n);…
 * Solution?
    Needs to check if the element exists on the webpage before try to 
   removeChild.
    -  This topic was modified 5 years, 9 months ago by [darknessfx](https://wordpress.org/support/users/darknessfx/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fue-cooki%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Thread Starter [darknessfx](https://wordpress.org/support/users/darknessfx/)
 * (@darknessfx)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/ue-cooki/#post-13157950)
 * Solved:
    Edit /wp-content/plugins/jetpack/_inc/build/widgets/eu-cookie-law/eu-
   cookie-law.min.js Column 1391 Replace: n.parentNode.removeChild(n) With: try {
   n.parentNode.removeChild(n)} catch (error) {}
 *  Plugin Support [KokkieH](https://wordpress.org/support/users/kokkieh/)
 * (@kokkieh)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/ue-cooki/#post-13159032)
 * Hi there,
 * Can you please expand a bit on the steps to replicate this issue? I don’t understand
   exactly what you described above.
 * Alternatively, as you’ve already figured out how to fix it, do you want to open
   an issue and submit a pull request for this on GitHub directly?
 * [https://github.com/automattic/jetpack](https://github.com/automattic/jetpack)
 *  Thread Starter [darknessfx](https://wordpress.org/support/users/darknessfx/)
 * (@darknessfx)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/ue-cooki/#post-13167764)
 * Hi there,
 * How to replicate:
    Open WordPress Admin Dashboard. Go to Appearance > Widgets.
   Add Cookies & Consents Banner (Jetpack) to your primary sidebar. Set Capture 
   consent & hide the banner to After this amount of time 30 seconds. Save. Visit
   your WP page (maybe using an European VPN?). The Cookies and Consent banner shows
   up, click Agree. Open your browser DevTool, check Console outputs. No errors.
   Press F5 (Refresh). The widget knows you already consent, so it don’t display
   the banner again. But. After 30 seconds, the timer script is still active to 
   destroy/remove the banner even if the script never created the banner this time,
   it fails to find the banner (n.parentNode = null) and throws this error (Cannot
   read property ‘removeChild’ of null).
 * I can open the issue ans commit suggestion on github, no problems.
 *  Plugin Support [fresatomica](https://wordpress.org/support/users/fresatomica/)
 * (@fresatomica)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/ue-cooki/#post-13180256)
 * > I can open the issue ans commit suggestion on github, no problems.
 * That would be great, our developers would be able to check this directly.
 * [https://github.com/Automattic/jetpack/issues](https://github.com/Automattic/jetpack/issues)
 * Feel free to link the issue you create in the reply. Thanks!
 *  Thread Starter [darknessfx](https://wordpress.org/support/users/darknessfx/)
 * (@darknessfx)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/ue-cooki/#post-13183055)
 * Done:
    [https://github.com/Automattic/jetpack/issues/16625](https://github.com/Automattic/jetpack/issues/16625)
 * Thanks!
 *  Plugin Support [fresatomica](https://wordpress.org/support/users/fresatomica/)
 * (@fresatomica)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/ue-cooki/#post-13184156)
 * Awesome, thank you!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘EU Cookie Law – Script error’ is closed to new replies.

 * ![](https://ps.w.org/jetpack/assets/icon.svg?rev=2819237)
 * [Jetpack - WP Security, Backup, Speed, & Growth](https://wordpress.org/plugins/jetpack/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/jetpack/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/jetpack/)
 * [Active Topics](https://wordpress.org/support/plugin/jetpack/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/jetpack/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/jetpack/reviews/)

## Tags

 * [script error](https://wordpress.org/support/topic-tag/script-error/)

 * 6 replies
 * 3 participants
 * Last reply from: [fresatomica](https://wordpress.org/support/users/fresatomica/)
 * Last activity: [5 years, 9 months ago](https://wordpress.org/support/topic/ue-cooki/#post-13184156)
 * Status: resolved