Title: Javascript conflict with cookie-notice
Last modified: January 3, 2020

---

# Javascript conflict with cookie-notice

 *  Resolved [jkeasley2](https://wordpress.org/support/users/jkeasley2/)
 * (@jkeasley2)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/javascript-conflict-with-cookie-notice/)
 * The javascript you are using is conflicting with the javascript used in the cookie-
   notice plugin.
    -  This topic was modified 6 years, 5 months ago by [jkeasley2](https://wordpress.org/support/users/jkeasley2/).

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

 *  Plugin Author [Eirudo](https://wordpress.org/support/users/eirudo/)
 * (@eirudo)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/javascript-conflict-with-cookie-notice/#post-12291195)
 * Hello, can you provide the link or the screenshots?
    Because I’m already try 
   to install Cookie Notice plugin and there’s no JS conflict.
 * Are you sure the problem coming from YouTube Responsive Plugin?
 *  Thread Starter [jkeasley2](https://wordpress.org/support/users/jkeasley2/)
 * (@jkeasley2)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/javascript-conflict-with-cookie-notice/#post-12297037)
 * Hi, the site which is displaying the issue isn’t publicly available, as it is
   a the stage instance of [https://md.catapult.org.uk](https://md.catapult.org.uk),
   and the and the cookie notice module on the production site hasn’t been updated
   due to this issue.
 * The observed behaviour is that where the site is loaded in incognito mode (to
   simulate a first visit to the site from a user) the cookie notice display doesn’t
   display as expected. no errors are output to the browser console.
 * The cookie notice plugin is used on sister sites to this site, and operates as
   expected.
 * On doing some investigation it was discovered that the issue is being caused 
   by the javascript used to check the cookies and display the notice as necessary
   wasn’t running as expected, with the init function not being run.
 * On disabling javascript in the other installed plugins on a 1 by 1 basis, with
   was found that if the javascript in wp-content/plugins/simple-youtube-responsive/
   js/youtube-responsive.min.js was commented out the cookie-notice plugin then 
   operates as expected.
 *  Thread Starter [jkeasley2](https://wordpress.org/support/users/jkeasley2/)
 * (@jkeasley2)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/javascript-conflict-with-cookie-notice/#post-12297384)
 * Having poked around to get things working again, the issue here is that window.
   onload is being used by both plugins, so the last javascript loaded overrides
   any previous javascript attached to the window.onload event.
 * I have resolved the issue by changing your javascript slightly
 *     ```
       window.addEventListener("load", function () {
        //your code unchanged here
       }, false);
       ```
   
 * This resolves the issue for us, and is also a safer way of ensuring that the 
   javascript is loaded when the window loads than attaching the javascript to the
   window.onload event.
 * I am going to raise a similar bug with the cookie_notice developers to see if
   they can make a similar change to their init method 😉
 *  Plugin Author [Eirudo](https://wordpress.org/support/users/eirudo/)
 * (@eirudo)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/javascript-conflict-with-cookie-notice/#post-12299067)
 * Hello jkeasley2,
    thank you very much for helping find out the issue 😀 I’ll 
   update the plugin soon. And I’ll include your username to update logs, because
   this bugs will remain exist without your help.
 * Thank you 🙂

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

The topic ‘Javascript conflict with cookie-notice’ is closed to new replies.

 * ![](https://ps.w.org/simple-youtube-responsive/assets/icon-256x256.png?rev=2869838)
 * [Simple YouTube Responsive](https://wordpress.org/plugins/simple-youtube-responsive/)
 * [Support Threads](https://wordpress.org/support/plugin/simple-youtube-responsive/)
 * [Active Topics](https://wordpress.org/support/plugin/simple-youtube-responsive/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simple-youtube-responsive/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simple-youtube-responsive/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Eirudo](https://wordpress.org/support/users/eirudo/)
 * Last activity: [6 years, 5 months ago](https://wordpress.org/support/topic/javascript-conflict-with-cookie-notice/#post-12299067)
 * Status: resolved