We offer a unique product in the form of a widget that can be integrated into websites. This widget consists of a single JS file that includes angular for functionality. However, a problem arises when a website already has angular loaded independently - an error is triggered, disrupting the site with the message:
WARNING: Tried to load angular more than once
This error occurs because angular is being loaded twice.
Our goal is to address this issue by either:
- Renaming or isolating angular in our script to avoid conflicts with the host site's version of angular, or
- Detecting if angular is already present on the site and refraining from loading it again.
While providing specific code examples may be challenging due to the complexity of our system spread across multiple files, our approach is based on the angular seed project utilizing requirejs for module loading. We then compile everything into a single file: https://github.com/tnajdek/angular-requirejs-seed
We welcome any advice, feedback, or solutions to resolve this issue.
Please note that this is not related to typical "check if angular loaded correctly" queries. The challenge lies in renaming angular within our widget package when it's already loaded on the parent page.