Question

I have two JavaScript files that contain a jQuery function with the same name $().

How can I distinguish between the two identically named functions?

Was it helpful?

Solution

Rename one.

$ = typeof $ !== 'function' ? $ : $foo;

OTHER TIPS

Short answer: You can't. All includes js files live in the same namespace.

Perhaps you want Using jQuery with Other Libraries, but I can't tell exactly what your problem is from the question. Perhaps you could include some sample code of the problem you're having?

Try using a namespace for each project you work on. For instance, instead of writing a function called dosomething(), call it myproject.dosomething()

That way, it is project specific and you will avoid having two identically named functions, even if you are including files you did not develop yourself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top