Problem loading external libraries (compile errors)

So we’re trying to incorporate an external library into our game called MessageBus (so the server can update the clients in a rapid fashion, but only when needed after certain events occur).

The library is here:

I was hoping to just get message-bus.js and put it into PlayCanvas along with jQuery and have it work, but as frequently happens when I pull other .js into playcanvas, the scripts are unable to parse.

Trying to eliminate the possibility that it’s just some error in the external library (though the backend engineer tested this .js and it works just fine outside of playcanvas), I tried to simply download and import jQuery - got the uncompressed version of 3.2.1 from here, copied the entire file and put it into playcanvas and changed the script load order so it’s the first one loaded.I hit parse and it comes back with this error:

What am I doing wrong here? I’m new to web programming, but jQuery seems like a generic library. I’ve seen other people talk about importing libraries and the official method seems to be by just copying and pasting the .js. Shouldn’t this just work?


Hmm… Odd. I’ve dragged both the messagebus library and jquery into a blank new project with no problem on launch. I assume you got that error when you parsed it? In which case, I wouldn’t worry about the error as the ‘parsing’ in the editor is for PlayCanvas scripts.

I see that in the project they are not loaded anywhere on objects. I guess I assumed they needed to be to be executed and available?

When I put the jQuery script on a basic gameobject for example I get this error when I launch the client:

Every js script you put into the project is automatically loaded. They do not need to be attached to entities to ‘run’. The only ‘scripts’ that can be attached to entities are the PlayCanvas ‘scripts’ objects which are defined in the script files.


var Sandbox = pc.createScript('sandbox'); // Creates a PlayCanvas 'script' object

I’m not even sure how you managed to do that :confused:

I’ve just done a little jQuery in my project to test.

Can you share the project? It will make it easier to debug.

Best way to show this is if you look at the source of the launch window, you can see how the scripts are loaded if you wrote it in pure HTML