Title: JavaScript global namespace pollution
Last modified: September 26, 2022

---

# JavaScript global namespace pollution

 *  [ibugone](https://wordpress.org/support/users/ibugone/)
 * (@ibugone)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/javascript-global-namespace-pollution/)
 * This plugin interferes with [WP PDF Embedder](https://wordpress.org/plugins/pdf-embedder/)
   in the Gutenberg editor and causes that plugin to show “Your site doesn’t include
   support for the PDF Embedder block”.
 * I identified the cause to be a JavaScript variable defined on the first line 
   of `assets/js/block-notice.js`, while the other plugin also defines `var __ =
   wp.i18n.__`. Since both plugins define this variable only for internal use, putting
   the definition at JS file level causes a global [namespace pollution](https://stackoverflow.com/q/8862665/5958455).
 * One possible solution is to wrap the whole script inside a [self-executing function](https://stackoverflow.com/q/592396/5958455),
   or better yet, since it’s only used once, remove the variable definition and 
   use the full namespaced path (i.e. `wp.i18n.__(...)`).
 * I have already contacted the developers of the other plugin, but it would certainly
   be nice if this can be fixed on both sides. Namespace pollution is known as a
   bad practice and makes plugins susceptible to conflicts.

The topic ‘JavaScript global namespace pollution’ is closed to new replies.

 * ![](https://ps.w.org/tuxedo-big-file-uploads/assets/icon-256x256.png?rev=2551772)
 * [Big File Uploads - Increase Maximum File Upload Size](https://wordpress.org/plugins/tuxedo-big-file-uploads/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tuxedo-big-file-uploads/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tuxedo-big-file-uploads/)
 * [Active Topics](https://wordpress.org/support/plugin/tuxedo-big-file-uploads/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tuxedo-big-file-uploads/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tuxedo-big-file-uploads/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [ibugone](https://wordpress.org/support/users/ibugone/)
 * Last activity: [3 years, 8 months ago](https://wordpress.org/support/topic/javascript-global-namespace-pollution/)
 * Status: not resolved