Skip to content

Instantly share code, notes, and snippets.

@retoheusser
retoheusser / angular-in-angular.md
Last active June 23, 2017 08:29
Multiple versions of Angular on the same Website

Multiple versions of Angular on the same Website

When developing JavaScript applications that need to be embedded into other websites that are controlled by other code than yours, you should be careful about what you expose globally and should prevent polluting the global namespace (the window object) as much as possible. This can rather easily be achieved with your own code. But what if you depend on third-party libraries such as jQuery, Lodash, Moment.js or Angular.js? All of these put themselves onto the window object regardless whether the original site is already using the same library, probably a different version. And you should just rely on exactly the versions you use within your code and not theirs nor should you overwrite their versions and potentially break their whole application.

I was facing all of these issues because my application needed to embedded into all kinds of environments which already use jQuery or lodash (very common) and even Angular. The Angular.js library even prevents lo