• Building
  • Optimize for HTML5? How to load zip?

Hello guys,

I'm new with Godot. I have finished some scenes in new project. After a few days of searching, still can't figure out how to make it work.

First, I tried to build custom template use Scons and it saved 2mb for wasm file, but it's still little big. I used wasm-opt and it can optimize wasm file upto 4mb but i can not use wasm-opt for custom template, i have no idea why, it cause many errors on wasm file of custom template.

Second, Follow this page, you guys said

Loading a .zip file instead of a .pck file as the main pack;

But i can't find any tutorial for how to load zip for main pack. Tried this https://github.com/godotengine/godot/issues/18384

const MAIN_PACK = BASENAME + '.zip';
if (!Engine.isWebGLAvailable()) {
	displayFailureNotice("WebGL not available");
} else {
	setStatusMode('indeterminate');
	engine.setCanvas(canvas);
	Promise.all([Engine.init(BASENAME), engine.preloadFile(MAIN_PACK)]).then(() => {
		return engine.start('--main-pack', MAIN_PACK);
	}).then(() => {
		setStatusMode('hidden');
		initializing = false;
	}, displayFailureNotice);
}

The result return alert note "is .pck file missing?". Do you guys have any example how to load zip for main pack? Thank you!

6 days later

Second, Follow this page, you guys said

Loading a .zip file instead of a .pck file as the main pack;

You could enable the web server's gzip or Brotli compression for .pck files to get a similar size benefit over the wire.

2 months later

Expanding on Calinou, what you would be doing is having the server provide a compressed version of the files while the user is downloading them so they transfer fast but also have the server let the browser know they are compressed so the user's browser decompresses them before launching them.

You as well as the user don't need to do anything fancy and won't even know something is happening in the background, it is all up to the server. You have to enable this on the server, however.