• Resolved Remco

    (@rembem)


    Hi,

    I ran into a script conflict on a site using CookieYes alongside another plugin, which may be worth flagging.

    In your frontend script (/wp-content/plugins/cookie-law-info/lite/frontend/js/script.min.js), near the top, you declare:

    const ref = window.cookieyes;

    Because this is at the top level of a classic <script>, ref is claimed in the global scope. Any later script on the page that tries to declare its own ref (even with var) throws a SyntaxError: redeclaration of const, which aborts parsing of that file entirely.

    In my case the other script was an older style minified library with a top-level var ... ref, ref1, ... — perfectly legal on its own, but it fails to parse the moment CookieYes has loaded first. The effect is breaking unrelated functionality on the page.

    I’ll add the other script in an IIFE to fix it. But as ref is a very common identifier, it seems likely to collide with more than just my case. Maybe it would be an idea to rename it, or wrapping the file in an IIFE, or building it as a module.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Nick

    (@nickcysupport)

    Hi @rembem,

    Thank you for taking the time to investigate this and share such detailed findings.

    We appreciate the explanation regarding the potential global scope conflict caused by the ref declaration. We have already forwarded your observations to our development team for further review and consideration.

    We also appreciate you sharing the workaround implemented on your end.

    Thread Starter Remco

    (@rembem)

    Looks like this is fixed in 3.5.1. Thanks!

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

You must be logged in to reply to this topic.