Avoid Global Namespace
See original GitHub issueI developed an embeddable widget which makes use of Pusher. Pusher is required from npm and my final js file is bundled using browserify
.
As Pusher makes use of window.Pusher
it is creating conflicts when the page using my widget is already making use of Pusher.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:13 (11 by maintainers)
Top Results From Across the Web
Is “Don't Pollute the Global Namespace” Still Good Advice in ...
In an effort to prevent naming collisions, experts labeled this practice as “pollution of the global namespace”. Example of global namespace pollution:
Read more >JS tip - Avoiding polluting the global namespace - BigBinary
Polluting global namespace is not good. This blog presents a better technique.
Read more >How to avoid namespace pollution in Javascript
I found this brilliant post about namespace pollution, which notes that - beside of conflicting name definitions - using global variables ...
Read more >Global NameSpace Pollution In JavaScript - Medium
In this article we will understand what is Global Namespace Pollution is in JavaScript and How to overcome this problem in javascript.
Read more >What is global namespace pollution in JavaScript?
Polluting Global namespace causes name collision. This name collision is very common in large projects where we may be using several ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yep, that worked! Thanks for the workaround. I’ll be on the lookout for a more permanent solution.
@mgalgs - could you try the worker build (
pusher-js/worker
)? This will work readily in the browser and does not (if memory serves) attach itself to the global namespace. The caveat is that it uses fetch for auth requests + sending stats to Pusher. This means on some older browsers (IE ≤ 11) and Safari, it will require a polyfill: https://github.com/github/fetch.