underscore.string
underscore.string copied to clipboard
Question: Change the global s
Hello,
a marketing tracking js library is override the global s variable from underscore.string in my app.
May I change the naming of the global variable to something else?
We should add jQuery style s.noConflict()
.
But if you can inject code between the libraries you can workaround it like this:
<script src="underscore.string.js"></script>
<script>
// Copy the s global to _s and allow s to be overridden
window._s = window.s;
</script>
<script src="marketing.js"></script>
But of course the best solution would be to adopt a module system and stop using globals.
thx, this solution works.
@epeli Do you still think we need noConflict
or is this solution enough? IMO it's enough
I would not oppose it if it were implemented.