underscore.string icon indicating copy to clipboard operation
underscore.string copied to clipboard

Question: Change the global s

Open Piioo opened this issue 9 years ago • 5 comments

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?

Piioo avatar Apr 09 '15 13:04 Piioo

We should add jQuery style s.noConflict().

esamattis avatar Apr 09 '15 13:04 esamattis

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.

esamattis avatar Apr 09 '15 13:04 esamattis

thx, this solution works.

Piioo avatar Apr 13 '15 07:04 Piioo

@epeli Do you still think we need noConflict or is this solution enough? IMO it's enough

stoeffel avatar May 02 '15 09:05 stoeffel

I would not oppose it if it were implemented.

esamattis avatar May 04 '15 13:05 esamattis