Skip to Content
avatar image
Former Member

How to load an external javascript file synchronously in SAP Design Studio custom component?

Dear All,

Context -

I am creating a custom component in Design Studio which requires a non AMD enabled (Async not supported) javascript module to be loaded. So, it doesnt support async attribute on script tag.

I understand that requirejs is used for loading javascript libraries in SAP Design studio custom component - this could be standard way.

Is this a limitation in SAP Design studio component that there is no way to load an external javascript file synchronously?

If there is a way, could you kindly share a sample code on how to load a non AMD enabled javascript file in SAP Custom component. Please suggest if I have any alternative solution to this problem.

Thanks for your help!

Add comment
10|10000 characters needed characters exceeded

  • Former Member

    Dears, I have seen the articles/questions that you have put on this blog, interesting but I couldnt find a way for loading external javascript files synchronously in Design Studio Custom component (Design Studio 1.6). Could you share your experience on this part please? Mike Howles Former Member Reiner Hille-Doering Martin Pankraz

  • Get RSS Feed

1 Answer

  • Best Answer
    Dec 18, 2017 at 04:26 PM

    Hello Satheesh,

    indeed requireJS is the recommended way to load JavaScript files for an SDK component. However there is still the older <jsInclude> loader available that loads JavaScript files by adding entries with a non-async <include> element.

    If this is sill not synchronous enough, you can use in your main component.js file jQuery's ajax or get APIs. They can load you JavaScript with a synchronous AJAX call and evaluate it with eval(). This is not very elegant, but would probably the only way that will work for some cases.

    Regards,

    Reiner.

    Add comment
    10|10000 characters needed characters exceeded