I have a pretty simple 2D platformer I’m trying to export to WebGL. I’ve followed the guide here and made sure to set it the recommended way. If I do an export using the Web Player Plugin my game comes out to be 1.3MB, which is nice on my hosting bandwidth. However the WebGL export comes out to be about 10MB (that’s only counting the compressed folder), which is quite the jump.
I noticed that even a blank project comes out to roughly 3MB (which is roughly near the numbers from this thread), so even a blank project is double the the size of my game using the plugin.
Is this just the current state of WebGL in unity? Are these size exports expected, or is there perhaps something else I should be doing to optimize my export? Is this kind of ratio the norm?
10 MB does not sound unrealistic. When comparing to the Web Player, bear in mind that the build size for the web player does not include the Unity engine runtime itself, as that is part of the plugin (and is re-downloaded whenever it needs a new version, which adds roughly 10 MB to the Web Player run).
We will try to get these sizes to be smaller, but for small project, the web player not having to include the Unity Engine in the build means it will always be smaller.
Bundling the engine into the download makes sense, I hadn’t though of that. I’m guessing that’s why just adding a few extra properties to your game (like a 2D RigidBody) balloons the size out because it now has to include the whole physics library. I’ll go through my game then and see if there’s anything that can be removed.
Would it be possible to take all the engine code (the code separate from just my game code) and move it out to a CDN hosted js file? Like what jQuery does with their libraries? I wouldn’t mind the extra few requests in my browser if it meant I could offload 90% of the code to another host.
I’m not sure if the file size is 10 times bigger, however, we usually get that on our webplayer and webgl ports of those games. I’m happy if we get webgl ports below 50-60mb thou, but I hope that the file optimization in webgl will be improved in near future.