HTML / Javascript Implementation

Hi, I’ve been looking into using HTML / CSS in the editor rather than outside. It’s going fine using the examples. Kinda stuck with the Javascript part though, I’ve looked through the examples and understand how you use listen events bound with CSS elements etc.

But I’m struggling to understand how you use / where you put all the rest of the Javascript code? I’m essentially disecting a single page application into Playcanvas, so I’ve found where the HTML and CSS go but not the Javascript.

Up to this point its all been embedded in the HTML file between the tags, I cant share the editor scene since its a commercial project unfortunatly.


Hi @Arnie ,

You can put your Javascript code in any regular PlayCanvas script, just make sure it executes after the HTML has been added to the page.

Check this example, it adds the HTML and then it executes JS code specific to that HTML: