Skip to Content

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

Oct 17, 2017 at 09:43 PM


avatar image
Former Member

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!

10 |10000 characters needed characters left 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

* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Reiner Hille-Doering
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.



Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member