A few questions about web exports in general

Godot Version

4.3

Question

Hello everyone,
It’s my very first post here so hopefully it is allowed to ask multiples questions in one subject rather than creating a topic for each of them. I’m making my first game and I have some troubles about exporting to the web. Hopefully it’s tagged properly as well.

  1. What is the best approach to load data from outside of the game, but on the same server (my website)? I guess I have to use the HTTPRequest node but then, how can I use a relative adress and not an absolute one to load my “data.gd” file?
  2. How to “embed” the game in a page? Right now, the game IS the page, and I want something like you can see on itch.io, but to my knowledge, the HTML shell provided in the export is more for customisation “on the fly”. I would rather build the website separately, then embed the game wherever it fits, but every ressource that I find online talks about the standard HTML export.
  3. I found a way to reduce the size of the game by using a compression system as described here. Calinou (who I believe is a Godot dev) says that it’s better to use Brotli and provide a script for the server, but I’m not smart enough to figure it out on my own… Does anyone know how to do it? (I would host the game on my own, NOT on itch.io so I have access to server settings through CPanel, if that matters).
  4. The index.wasm that is generated (before compression) is about 34Mb.I want to reduce it even further by stripping fonctionalities that I don’t use in my game (3D for instance)? How would I do that? It says here that it is possible but I have no clue. I don’t understand what “scons” is and where to put it.
  5. I may be blind but I don’t find any info about how to change the loading bar. As I use an archive, I suspect the loading to still refers about the “normal” size of the index.wasm rather than the reduced size, which cause the bar to stop at 25% because, well, it’s loaded.
  6. And finally, I noticed that Firefox “leaks” memory when I play my game. That does not happen on other browsers and I checked memory leaks in the inspector before export. I don’t have any orphan nodes or an infinite number of objects creating themselves… But Firefox increases it’s RAM usage by like 6Mb every two seconds. Any thoughts or clues?

And… That’s about it! :sweat_smile: Thanks a lot if you read the whole thing!

3 Likes

I would love to read the answer to these questions

Hello friend. I don’t know everything but I’ll try to answer with what I know. If anyone more experienced than me would like to add anything or correct me, please know that it’ll be very appreciated and I thank you in advance.

  1. What is the best approach to load data from outside of the game, but on the same server?

A: Why do you want to load information from a server? Is your game multiplayer? Otherwise, generally speaking it’s not wise to make your game retrieve information from outside. If you need anything in your game that can be packed into it when building it, then just do so.

  1. How to “embed” the game in a page? Right now, the game IS the page, and I want something like you can see on itch.io

A: If you want to develop a game to launch it on itch, then you can export it to Web (HTML5), name the file “index”, preferably export it to an empty folder (I name mine “webexport”) then ZIP everything that it generates, then upload it to itch. If you publish it to itch, they’ll kindly give you the code needed to embed it to somewhere else.

If you aren’t going to publish it to itch, then please read on the documentation about How to serve the web exported files. The game uses all the available space on the page, so you can embed it to an iframe easily, as mentioned by the documentation; I would recommend that you do so as well, unless you have a good reason not to.

  1. I found a way to reduce the size of the game by using a compression system as described here (link).

To be honest, I’m not entirely sure what it does but it seems to me that it’s a SH file that automates the instructions given here: (reddit) [GUIDE] How to compress wasm/pck file
Reading further and doing some tests, these posts date back to 2020, and my webexport’s JS file does not have a function named loadXHR (and probably yours too), so this was probably intended to work with an older version of Godot. But what it does is explained in the reddit post I linked to, if you’re still curious.

  1. What is the documentation telling me to do to reduce game size? What is scons?

If you are unfamiliar with cloning software from GitHub to build it yourself, this will not be easy for you, although I do not discourage you from learning it. What the documentation is saying, in fewer words, is that “the engine packs a lot of things into your game, most of which will probably not even be used in your game, so you can modify the engine itself to not have those in the first place; this will make your final product much lighter”. That’s why the documentation page (which you’ve linked) says:

Before continuing, it is recommended to read the previous tutorials on compiling Godot for each platform.

(sic.). Also, Scons is a build software, similar to the GNU make.

  1. I don’t find any info about how to change the loading bar.

Are you referring to the loading screen, with the Godot Splash Screen? I haven’t learned how to change that screen yet; however, I do know you can find detailed instructions on how to do this with a quick Internet search, because it’s in my list of things I have to learn next.

  1. I noticed that Firefox “leaks” memory when I play my game.

I am not aware of this. Maybe this is a bug; you should probably open an issue about this on the Godot’s GitHub page. Even if this isn’t a bug, someone will probably help you find what’s wrong.

====================
I hope these answers will help you. If you have any further questions, please feel free to ask them.

2 Likes