Can I add JS libraries into user.js?

I've been using some additional javascript library files, but I'm doing lots of testing and adding them in each time is taking too long and I would like them to load automatically.

Can I just add them into a function which will load as part of user.js with all the other functions?

Is there a way to do something equivalent to this?

8 Replies
Steve Flowers

Hey Luke - 

Couple of ways to do this. If you're referencing libraries on CDN, here's the way I do this in a Javascript Trigger that runs when the timeline starts (added to user.js on publish). In this example, I added the library files to a Web Object, published to reveal the relative path, and added those paths. If using a CDN, you'd change the add_script parameter to your absolute CDN reference.

function add_script(scriptURL,oID) {
var scriptEl = document.createElement("script");
var head=document.getElementsByTagName('head')[0];
scriptEl.type = "text/javascript";
scriptEl.src = scriptURL;;

//only want to add these once!


Steve Flowers

It's the file that the WebObject needs to launch. If there isn't an index.html file, the folder won't be ingested. I import a WebObject containing my baggage into a slide that isn't accessed, in a scene placed "Off to the side"

If you don't include an index.html file, the WebObject workflow won't complete.