How To Add an External .js script

Hello I wanted to add an external javascript .js script.
I added it to a component ‘Screen’ -> State -> ‘Edit Script’

Using the following code:

var script = document.createElement(‘script’);
script.src = ‘http://localhost:4000/Built.js’;
var head = document.getElementsByTagName(“head”)[0];
head.appendChild(script);

But the .js file loads and executes its code multiple times.

Is there an easier way to do this?

1 Like

Hello. How to add external script and use it in React Studio? I get ‘undefined error’ even though i can call a function from the ‘Browser console command line’

Hi, currently there is no way for adding external javascript files but we’re going to make few tests and let you know if we find a generic solution for this.