Through a special package from Unity itself, you can see that the assembly includes a bunch of debug things and most importantly - a bunch of duplicates that apparently cannot be removed from the assembly and thus they occupy not a small part where size is so important for the Web
Which package is that?
How much is “not small” in bytes?
You may notice that a default project loads within about one second.
You can then strip this build as much as you want but the initial (empty cache) load time will not change noticeably.
If you aim for the utmost fastest download speed on a 3G or even Edge mobile device and loading time for these devices is critical to you I’m afraid Unity (still) isn’t the right tool for the job. But if we’re talking about moderately fast devices (4G) or even desktop, the differences to native engines is close enough to not matter anymore.
The rest is up to you, eg when you add content the use of Asset Bundles / Addressables can greatly speed up the initial load times since these can be downloaded as needed in the background while the user may still be navigating the menu.
Obsessing over a few KiB of the initial build size is a waste of time better spent on learning, implementing and designing the game around asset bundles/addressables.
That is a bit exaggerated isn’t it? From click-to-render, it’s easily 3-5 seconds without any splash screen with Brotli compression and non-local server for first load (non-cached, which is what the majority of users will experience).
In terms of UX, that is a -LONG- time. Adding anything else, makes this reach 5+ seconds.
Code init is the biggest culprit, as the player loads quite a few assemblies that are heavy but not used.
Using addressables mitigates assets loading times but it’s not perfect. There are A LOT of issues with addressables on WebGL, some that force users to put references directly in resources / main scene. We just had one where references to render texture wouldn’t hold in an addressable scene and had to be forced in the player data.
So it’s not about a few KB - It’s about putting light on the fact that the player -needs- to be as lightweight as possible and its sloppy to have production-level builds where temporary, unused assets are loaded.
Just for that, I have to agree with @Gamma_Snaplight
In general, I found a workaround for how to cut out such things, for example, there are no XR shaders in my build anymore, which for some reason are included in the Web build
It’s always appreciated if you could share your tips.
For XR, is it just stripping the build-in package and enforcing more strict shader stripping rules in the graphic settings of URP?
Not for me. I did test various games on the website Unity recently partened with to do the Crazy Game Jam. I was surprised to see many of these web games were made with Unity and the load times were often between 1-2 seconds. And my own builds also load that fast.
But results may depend on the user’s system (mine is a i9-14900K).
"com.unity.build-report-inspector": "0.3.0-preview"
Do it this way:
- Remove all modules, because many are built into the engine that will allow you to make a full-fledged game, but only in 3D
- Remove the logo in version 6 (-50 KB)
- Go to the editor files and rename 3 files to anything along the way - “…Editor\6000.0.31f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Resources”. It seems like these are all sorts of sprites by default, so far it has not caused errors if you do not use the built-in sprites (-130 KB)
- [Experimental solution] The question of how I deleted the XR shaders is to make the packages local in the project, after which there will be access to all files directly, I did so with the Universal RP package (Unity - Manual: Install a UPM package from a local folder ). After deleting the shaders, an error appeared that does not break anything, but which I have not yet figured out how to fix, because it leads to an auto-script in which there is nothing, the error is that it does not find shaders to add them to the database. To remove garbage prefabs, you need to make a local Core RP package. What I have realized so far is that if you delete something that is not required, it can lead to such errors that you will have to reinstall the edit editor. This method is for those who know what they are doing. I hope the developers will pay attention to this misunderstanding. Here I also unsubscribed - Unity 6 updates for platforms - #17 by Gamma_Snaplight . You can support my post there too