gauravmuk
gauravmuk

Reputation: 1616

Renaming Window Variable

I have arrived at a situation where I need to rename a window variable because of conflict arising from some other library which cannot be renamed.

Now, that global instance is being used extensively throughout the app like at thousands of places. Renaming is an option but is not trustworthy enough and checking all instances is a pain in it self. Is there any simple way of doing this?

What can be the best way to avoid any errors?

Some of the classes are wrapped inside define block and using IIFE will not be possible with them.

Upvotes: 0

Views: 136

Answers (1)

aliasm2k
aliasm2k

Reputation: 901

You can possibly wrap the global instance in an IIFE so that the global instance is no longer global.

Simply something like

(function() {
    //Your code here
}());

would be sufficient

Upvotes: 1

Related Questions