Some javascript libraries are distributed as a fully concatenated file, including all of the dependent libraries. Some libraries like JQuery provide a way to handle conflicts if multiple version of the library are being used. But if a compiled/concatenated javascript file contains a library that doesn’t have a built in way of handling conflicts and I am using that same library (but a different version), is there a general way to wrap the version I am using and add a custom namespace to it? Or is that dependent on the library being used?
Some javascript libraries are distributed as a fully concatenated file, including all of the
Share
It depends on the library. If it provides all functions under one namespace, you can include your version first, store a reference to it under a different variable/name, (unset the original if conflict could occur) and include the other library afterwards.
It would look like this:
The better thing of course is if
OtherLibraryWithDependencieswould properly encapsulate all dependencies so that they don’t leak into global scope.