Import and call External Javascript (continuous topic)

I have a almost same issue now.
Are there no other way to solve ?

I can import jQuery.js by adding The SCRIPT tag to downloaded index.html.
But other issue are there.

I make my games publish to an Japanese platform.
So I must call some common javascripts provided by the platform.
They connect to the platform API. and they procedure the function “user login” and “show ad”…etc.
I wanna importing external javascripts setting on same file path to make easy to maintenance.

Continuing the discussion from External Javascript:

For now, I have solved this issue by cut & paste code from these javascript library.
If there are other way, I will try it.

Instead of including the URL of the javascript file we recommend that you download the file that you require (e.g. jquery) and add the javascript file into your project.

Then you can load the file using the Script Priority dialog.

1 Like

Thank you @dave

I did your recommened method.
and I have talk with my project member, and seek the management way now.

1 Like

Sorry for the late reply @ogawa, I’ve been quite busy lately. It seems you have come to a solution as recommended by @dave.

Another solution is to download the project, edit the main HTML to include your scripts and host the project from your own server. But this process doesn’t really support using the fine editor on playcanvas efficiently.

@dave: What if we could include external scripts in the project settings, you could only allow other domains as the source - this would also lower the space required on the servers.

1 Like

External scripts lead to many challenges and complexities.
For example we need to parse actual script, to identify what playcanvas script objects it contains and parse their attributes, so we can show attributes in Editor UI.
Then those urls have to be reliable, and lets say today someone have scripts on some external server, and then he removed or change url of it, then what - your app wont simply work.
To avoid that - we would need to download those scripts during publishing? But that creates challenges, especially with SSL and the fact it still can be unreliable.

So many failure options here, and no benefits pretty much, especially when you can do everything you need by simply uploading that script.

1 Like

I thought the External Javascript are separated 2 groups.

  1. Permanent use
    These are always working or showing on HTML body.(for example, jQuery, footer ad banner)
    They are suitable for h4v0c shown method.
  2. Temporarily use (It is my this time issue)
    These are working in a part of time on the game.(for example, login dialog, popup ad)
    They are suitable for dave shown method.

So there aren’t simpley solution. I did these combined.