How to Optimize Unity Build Size for 2D Web Games

Post author: Orenji Spark
February 18, 2025
How to Optimize Unity Build Size for 2D Web Games

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:


Optimize IL2CPP Settings

In Player Settings → Other Settings:


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:


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.

Latest Posts