Support custom script tags to include external JavaScript code

Hi,

I’m building a PlayCanvas application that uses a npm dependency (managed via webpack) and some ClojureScript code (managed via Figwheel). Both build tools pull in a lot of transitive dependencies, so that it is impracticable to copy the sources over to the PlayCanvas code editor.

It would be great, if PlayCanvas would provide an option to add custom script tags to the html file of a PlayCanvas project.

Best regards

Max

You could add them programmatically in one of your scripts, or use Ajax requests to include them. Just make sure you use HTTPS otherwise when you publish you might face some cross origin request errors.

Thank you for your answer. I already add them programmatically, which works fine for the npm dependency. But ClojureScript uses Google Closure underneath and this one uses document.write to include further JS files. However document.write is not possible anymore, when the document is already loaded / in the ready state. Libs like https://github.com/krux/postscribe provides workarounds for this.

It is still very difficult to make this work with FigWheel, since it has a very interactive development workflow. An option to include an additional script tag in the main html header would make PlayCanvas + FigWheel easy to use.

At the moment I either have to compile the ClojureScript into one JS file or download the PlayCanvas project, add the two JS script tags to the index.html and start a http-server to serve the PlayCanvas project on localhost.

Any news if this might added as a feature?

It’s not very clear to me what exactly you’re trying to achieve with all these different frameworks. Because I haven’t used that workflow you’re using could you briefly explain what you’re doing?

In general we avoid adding features that can already be achieved by most people unless we understand that this is something that people will generally need.

Are you using the Editor for all this or are you hosting the project locally?

I’m building a cardboard experience that also shows a video ad. The ad is loaded from an ad server that delivers a VAST ad tag. For this purpose I’m using this library: https://github.com/dailymotion/vast-client-js it has quite a few dependencies. I’m writing the other necessary integration logic in ClojureScript.

I could also host the project locally, but I would need to download the project everytime I like to make a change in the editor / in the 3D environment. Having an option (in the editor UI) to include custom script tags via the editor would also be helpful to include JavaScript libs from CDNs instead of copy pasting them into a JS file in PlayCanvas.

We don’t really support ClojureScript for the Editor. We used to support custom URLs instead of scripts but for various reasons we dropped support for that.

Would it be possible for you to use simple JavaScript for your project? Adding custom script tags is not something we are considering at the moment. It might change in the future but it’s not really in our roadmap at the moment.

Our complete system is written in Clojure / ClojureScript therefore we try to use it wherever possible to reuse knowledge, tools and code. By compiling into one JS file I can work with PlayCanvas plus ClojureScript. But I don’t have support for source maps and no live coding (Figwheel).