Has anyone ever tested this? For arguments sake lets say there are zero assets in the project. One simple scene being built with nothing except a camera and directional light. With the highest compression and stripping what would the smallest possible webgl size be?
Have optimized every single asset dowe to the kilobyte but am left with huge UnityEngine DLLs clogging up the build. Current build size is 18MB and System DLLs, Script DLLs, and UnityEngine take about 12MB.
My last WebGL build was less than 10 MB and ~5 MB is supposedly (read that in some other thread) about as low as you can go - but this changes between Unity versions.
UPDATE: I [investigated minimum WebGL build sizes]( WebGL builds for mobile page-2#post-9021013) here (1.8 MB for Legacy, 3.5 MB for URP). That thread contains a lot of other useful info as well.
thank you for the reply. ~5 MB is definitely the goal. Good to know that this is actually achievable. By release mode do you mean not developer mode? I rarely use developer mode when building to webgl.
In terms of Unity versions I just made the fatal error of upgrading to 2022.2.17 and now all my webgl builds hang permanently on “linking build.js”
The smallest build I achieved was 2.47MB with Unity 2020.3 with builtin render pipeline and brotli compression targeting webgl1. This build includes a simple test scene with some falling blocks and I also didn’t start manually stripping out builtin packages, so I think you can go een a bit lower than that. You can test the build yourself here: WebLoadingTest
And that is the repo to see the exact setup I’m using: GitHub - JohannesDeml/UnityWebGL-LoadingTest: Unity WebGL platform and version comparisons with a lot of nice extras
To get the settings for the min size build, just build the project with minsize, then it will apply all settings that are used for that to the project settings
Glad you find it useful!
Yes, that would be the winner, but tbh I would recommend to go with Unity 2021.3.x, since that is the LTS version, and the difference in build size is not that big. If you want to see and test all the builds I did over the years, you can find them here: https://deml.io/experiments/unity-webgl/
Note however, that the unity template and functionality grew a bit over time, so older build versions might have less KB. The list of builds on the github page is a fair comparison, since they all use the same template.
Regarding release, check the player settings. You want to tick all the release buttons, disable exceptions and all that.
However for development you should definitely make debug/dev builds because they can be done in 2 min. vs 20 for a release build. Check what the build time is for your project in dev vs release builds, and do each build twice so you can see the truly incremental build speedups.
As to upgrading and running into troubles, my experience is that you are most likely have to debug the issue. It’s comparatively rare that it’s a specific Unity issue and waiting will get it fixed. In any case, try 2022.2.0 and see if it works there. If it does you can work your way up to the highest version that still builds your project, then check the changelogs for the next version for any hints regarding what may trigger the issue.
This guy is right, I followed his project and packed success as a 3.5Mb build .apk or folder(no need webgl, or URP), I wonder who said URP is small first; The logic is if URP is small, then built-in is no need to exist(It’s nothing about render & graph) ; Besides, 99.9% information in forum will tell you compress, compress, yes it work if you could compress a png file. but you ever done it and you konw how to compress pixeles with code? if not, you dont have any concept of compression of digital Asset, so please dont trust someone who want to teach you compress, you have to learn CS for your own
Note that with Unity 6 Preview you can disable the splashscreen logo which will remove a couple KB. As well as [what I did]( WebGL builds for mobile page-2#post-9021013), specifically disabling unused built-in packages can remove several hundred KB.
Also compression is about more than PNG files and build compression will lead to a smaller build - it only depends on the assets in the project as to how much compression can be achieved.
Huh??? If you don’t know how to compress assets in your project with the default unity options you are in for a very rude awakening. Like @CodeSmile said, 95% of reducing build size is the simply compressing textures and meshes with unity’s default options (even though there is still some confusion as to whether crunch compressed textures reduce the texture size in both disk space AND memory space or solely disk space) Example crunch compressing a 4096x4096 png to 128x128 only reduces file size and not memory. Lot of conflicting tests and unity docs all have inconsistent info. Other obvious benefit of crunching is the huge load time performance increase. Great info from bgolus in this thread: https://discussions.unity.com/t/721256
URP builds will evidently be slightly larger than BIRP builds because of all the package requirements like shader graph / mathematics / burst etc. The tradeoff is around ~2MB and you get all the benefits of URP on web. Not sure who told you URP can be smaller size than BIRP that’s just blatantly false info.
The packages actually (typically) contribute little to build size, unless they contain larger assets. From what I recall the majority of size increase of URP is due to materials and corresponding textures and shaders included in the URP and/or SRP packages.
Shader graph + Core RP library adds something like ~1.1MB if I recall correctly. TONS of prefabs from core RP package alone that get forced into build that include textures and debug ui nonsense. I mean I would gladly spend the time manually editing these packages but its kind of waste when unity just pushes new LTS is actually a giant step backwards and increases build size lol.
But hey we’re talking about +2 Mb tops. And nobody has done any measurements as to whether this actually increases load time, which would be the primary (only?) concern. If these assets exist in the build but aren’t used and thus not loaded I would expect them not to affect the load time.
Very true. At some point the time spent trying to decrease build size becomes counter productive, especially when your sifting through literal kbs of tiny insignificant files.
I think it comes down to sunk cost fallacy where you know you’ve already invested so much time keeping build size as small as possible, that skimping out at the end (however insignificant + tiny the size is like 2MB) seems like destroying all the previous work optimizing. Also if your final build size is like 6MB, those forced 2MB are now 30% off entire build. You spend all this time reducing and cleaning the size and then unity just takes a fat dump all over it at the end.
Or it’s just a mindset of not wanting unity forcing their disorganized fluff into pristine clean projects. Especially when the packages are mandatory and a pain / impossible to manually remove. But this also doesn’t make sense when you think about it because the entire engine itself is horrendously optimized and most likely filled to brim with unnecessary resources…
Also at this point, everyone has blazing internet / good enough phones that those added MB are quite literally negligible for download and load time.
It’s always funny to read these forum posts and see the vast differences in people’s final build sizes. Majority will have like 10-20MB builds but then some newbie will proudly proclaim how they got build down to like 250MB. (I don’t even want to know what % of that is solely textures or how long that build even takes to load in browser) It’s a huge learning curve which is somewhat ironic because I was that newbie seeking knowledge when I wrote this original thread over a year ago. In those 12 months I’ve done well over 10,000+ web builds and still haven’t come to final conclusion on what the “Smallest possible WebGL build size” is or will ever be
As long as you enable: Build Profile->Player Setting->Compress Formate->Brotli
your package will be as small as Unity can be. If you want smaller, remove UPR, input system, unity logo and so on.