When building 2D web games with Unity, keeping the build size small is important—especially if you’re targeting players with slower connections or want faster load times. In this post, I’ll share a simple checklist and tips focused on optimizing build size specifically for Unity 2D WebGL games.
While the focus here is web games, many of these tips can also be applied to 3D projects or non-web platforms.
Use Unity 6 (Or at Least a Recent Version)
Unity 6 introduced several build optimizations and better compression formats by default. If you’re still on an older version, upgrading can save you some headaches.
Project Settings for Smaller Builds
Here’s what I recommend configuring:
Choose 2D, Built-in Render Pipeline Template. When creating your project, select the 2D template with Built-in RP unless you specifically need URP. URP adds extra weight and is often unnecessary for simple 2D games.
Disable Splash Screen. Go to Player Settings → Splash Image and untick Show Splash Screen. This removes the Unity logo and saves a bit of space.
Set Publishing Compression Format to Brotli. Under Player Settings → Publishing Settings, look for Compression Format. Choose Brotli (or Gzip if Brotli causes issues). Brotli gives the smallest file sizes for WebGL builds.
If possible. Set Player Settings -> Publishing Settings -> Enable Exceptions to “None”. Becareful because this will make TryCatch on your script not work as expected.
Optimize IL2CPP Settings
In Player Settings → Other Settings:
Set IL2CPP Code Generation to Optimize for Size.
Set C++ Compiler Configuration to Master.
Set Managed Stripping Level to High.
Use Build Profiles → Code Optimization: Disk Size with LTO
In Build Profiles, make sure Code Optimization is set to Disk Size With LTO. This enables link-time optimization, reducing code size further.
Asset Compression Tips
Assets often take up the biggest chunk of your build. Here’s how to handle them smartly:
Use Sprite Atlas Packing your sprites into atlases reduces texture overhead and draw calls. It also helps Unity compress them more efficiently.
Use Textures with Width/Height as Multiples of 4 For example: 4×8, 8×8, 128×256.
Texture Compression: RGBA Crunched ETC2 For PNGs and sprite textures, set the compression to RGBA Crunched ETC2. This provides a solid balance between size and quality for WebGL.
Reduce Audio Quality Lowering the Quality slider on your audio assets can shrink the file size significantly. Find the lowest acceptable quality for your game.
Build Compression Results
By following these settings and compression techniques, I tested building a blank Unity project with just a few sprites and no UI or TextMesh Pro. The result was: 2.5–3 MB build size
That’s a good baseline for a lightweight 2D WebGL game.
Bonus Note: UI and TextMesh Pro
Including Unity UI or the TextMesh Pro package typically adds an extra 3–4 MB to your build. If you want the absolute smallest file size possible, consider using plain sprites or custom text rendering instead of built-in UI solutions.
Final Thoughts
Optimizing build size for Unity 2D web games doesn’t require advanced tricks—just attention to project setup, compression formats, and being careful with which packages and assets you include.