Import JS libraries

How could i import a ‘folder’ of JS libraries (e.g. http://www.getorgchart.com/Download)
It contains scripts, CSS, pictures etc.

The one SC provided are purely to input single scripts.

Thanks for the pointers

perhaps an echo in onapplicationinit allows you to write the include statement in your html code.

echo 'include … ';

There isn’t any import, include or require in JavaScript, but there are two main ways to achieve what you want:

1 - You can load it with an Ajax call and then use eval.

This is the most straightforward way, but it’s limited to your domain because of the JavaScript safety settings, and using eval is opening the door to bugs and hacks.

2 - Add a script tag with the script URL in the HTML.

This is definitely the best way to go. You can load the script even from a foreign server, and it’s clean as you use the browser parser to evaluate the code. You can put the <script /> tag in the head of the web page, or at the bottom of the body.

Both of these solutions are discussed and illustrated in JavaScript Madness: Dynamic Script Loading.

Now, there is a big issue you must know about. Doing that implies that you remotely load the code. Modern web browsers will load the file and keep executing your current script because they load everything asynchronously to improve performance.

It means that if you use these tricks directly, you won’t be able to use your newly loaded code the next line after you asked it to be loaded, because it will be still loading.

[QUOTE=weilies;24788]How could i import a ‘folder’ of JS libraries (e.g. http://www.getorgchart.com/Download)
It contains scripts, CSS, pictures etc.

The one SC provided are purely to input single scripts.

Thanks for the pointers[/QUOTE]

Hello weillies. So how did you eventually solve this challenge?

Upload the folder outside sc, then require it remotely