Can I import a Javascript library file (in this case sigma.js) in a self executing function?

356 views Asked by At

I use a technology that unfortunately relies on the old Prototype.js framework (check out that modern looking website!). I'd like to include a sigma.js graph on the page, but just put the script tag on to import sigma gives this error:

TypeError: sigma.utils.matrices is undefined sigma.min.js:2

I don't know the exact cause of this, although I have asked, but I think it's conflicting with Prototype.js.

Is it possible to put all my sigma.js code in a self executing function, along with the sigma.js import, so it doesn't conflict?

1

There are 1 answers

4
andrew On

Try like this:

(function(sigma){
 //your usage of sigma     sigma.classes.graph....
})(sigma);