Skip to Content
Author's profile photo Former Member

Include External Javascript Library in SAPUI5

Hello,

i needed to add externel Javascript libraries into one of our Fiori applications. It took me some time to figure out how this could be achived, as eg. jQuery.sap.loadScript() didn’t properly call the defined callback function. So here comes a working example – i know d3 is already included within sapui5, but i’ve needed another version as shipped in sapui5. This works also with other external js libraries.

jQuery.sap.registerResourcePath(“d3”, “../extjslib/d3”);

jQuery.sap.require(“d3”);

Have a nice day & kind regards,

Michael

Assigned Tags

      5 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Christian Guenter
      Christian Guenter

      Hi Michael,

      where do place the call to

      jQuery.sap.registerResourcePath("d3", "../extjslib/d3");

      jQuery.sap.require("d3");

      in your Fiori-App?

      Regards Christian

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hy Christian,

      i've placed it in the Component.js file.

      Regards,

      Michael

      Author's profile photo Former Member
      Former Member

      Hi Michail,

      Below is the screen of my project, I am developing a custom fiori app and launchpad for accessing the custom app. We need client side pdf generation so we are trying to include third party library marked in blue to accomplish the requirement.

      Please provide code or steps to include these files using component.js.

      I am aware of including third party library index.html, as are not using index we need component.js route of including these files.

      your reply is much appreciated!

      projectSC.png

      Regards,

      BG

      Author's profile photo Krishna Kishor Kammaje
      Krishna Kishor Kammaje

      It is better to use sap.ui.define instead of jQuery.sap.require as a best practice.


      Also other approach is to include it in Component.js in "includes" parameter under "metadata".

      Author's profile photo Wouter Lemaire
      Wouter Lemaire

      You should create question, not a blog.

       

      For your question, this is how I include other modules:

      https://blogs.sap.com/2017/04/30/how-to-include-third-party-libraries-modules-in-sapui5/