Title: Global const ref causing issues in other code
Last modified: May 27, 2026

---

# Global const ref causing issues in other code

 *  Resolved [Remco](https://wordpress.org/support/users/rembem/)
 * (@rembem)
 * [1 week, 4 days ago](https://wordpress.org/support/topic/global-const-ref-causing-issues-in-other-code/)
 * 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:
 *     ```wp-block-code
       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](https://wordpress.org/support/users/nickcysupport/)
 * (@nickcysupport)
 * [1 week, 3 days ago](https://wordpress.org/support/topic/global-const-ref-causing-issues-in-other-code/#post-18921466)
 * Hi [@rembem](https://wordpress.org/support/users/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](https://wordpress.org/support/users/rembem/)
 * (@rembem)
 * [1 week, 3 days ago](https://wordpress.org/support/topic/global-const-ref-causing-issues-in-other-code/#post-18921956)
 * Looks like this is fixed in 3.5.1. Thanks!

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

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fglobal-const-ref-causing-issues-in-other-code%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/cookie-law-info/assets/icon.svg?rev=3007243)
 * [CookieYes – Cookie Banner for Cookie Consent (Easy to setup GDPR/CCPA Compliant Cookie Notice)](https://wordpress.org/plugins/cookie-law-info/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cookie-law-info/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cookie-law-info/)
 * [Active Topics](https://wordpress.org/support/plugin/cookie-law-info/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cookie-law-info/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cookie-law-info/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Remco](https://wordpress.org/support/users/rembem/)
 * Last activity: [1 week, 3 days ago](https://wordpress.org/support/topic/global-const-ref-causing-issues-in-other-code/#post-18921956)
 * Status: resolved