Search code examples
javascriptjquerysapui5

Using external js libraries in sapui5


So I'm trying to inlcude an external .js file in my SAPUI5 Controller.

    jQuery.sap.includeScript("externalLibrary.min.js", 
    function() {
        //initalizing objects from library
    });

However, the callback which should be called once the script is loaded, never gets called. The error message it gives me is:

"externalLibrary.min.js:16 Uncaught TypeError: Cannot read property 'Constructor' of undefined"

Whats another way I could do this? I was looking into jQuery.sap.registerModulePath() and jQuery.sap.registerResourcePath() but couldn't find a good example of the use of these nor an explaination of the difference between the two online.

Thanks a lot!


Solution

  • Got it! For future reference, it works to load the files from the index html like so:

     <script src="library.js"></script>
    

    The main problem was that I was trying to include external dependencies which also contained jQuery. So, I had to remove that from the file and now it's working.