Boost the Performance of Your WebGL Unity Games!

Rate this content

Unity, when deployed on the web, faces three critical challenges: build size, memory usage, and overall performance. This lecture delves deep into advanced optimization techniques to help you address each of these issues. Attendees will gain insights into:

- Effective strategies for optimizing textures, audio, and models.

- A detailed analysis of our ASTC experimentation with Unity, shedding light on the unexpected results despite Unity's claims.

- A comprehensive guide to Unity's memory profiling tool and its implications.

- An exploration of lesser-known Unity settings that remain underutilized by many developers.

Additionally, we'll introduce our proprietary tool designed specifically for Unity optimization. We will also showcase CrazyGames' developer dashboard, our platform that enables developers to monitor and enhance the performance of their web-based games seamlessly. 

Join us to equip yourself with the latest strategies and tools to elevate your Unity web gaming projects.

7 min
28 Sep, 2023


Sign in or register to post your comment.

Video Summary and Transcription

The Talk discusses ways to boost the performance of WebGL Unity games, including issues with bundle size, memory usage, and runtime performance. It suggests using Brotli for compression and non-exception support for better performance. Choosing the appropriate texture compression format and experimenting with separate builds can also help. The Talk also covers optimizing textures, models, audio, and assets by reducing build size, using compression, disabling unnecessary models, and optimizing audio quality. Unity's optimization tools and profilers are recommended for analyzing performance and memory issues.

Available in Español

1. Boosting Performance of WebGL Unity Games

Short description:

I'll talk about boosting the performance of your WebGL Unity games. Unity web issues include bundle size, memory usage, and runtime performance. Brotli is recommended for compression due to its smaller size. Use non-exception support for better performance, but avoid full exceptions to reduce bundle size. Choose the appropriate texture compression format to save runtime memory. Experimentation with separate builds showed negligible improvements.

Hey, everyone, my name is Florin, and I'll talk today about boosting the performance of your WebGL Unity games. So a little bit about me. I'm a product engineer at Crazy Games, I'm also a game developer. You can see a couple of the games I created here. I mostly work with Unity, but I also do have some simple vanilla JS games.

At Crazy Games we're one of the biggest gaming platforms, we have more than 5000 games, we work with more than 700 developers and we also have 20 million of unique players. So yeah, let's start with the Unity web issues that you may encounter when building for the web. So there is the bundle size, it affects how fast your game loads, the memory usage, the RAM that basically your game uses when it runs, and the runtime performance. And why it's important to keep runtime memory usage low? Well, in the browser, Unity uses a memory heap to store the game data. And let's say you load a new scene, new textures need to be loaded, the browser may have to increase the heap size. And if a browser fails to allocate more memory to increase the heap size, you'll get this ugly popup that just crashes your game.

About the code performance, I won't talk about it here, so Oz already gave an excellent presentation about it, it's called Detect and Avoid Common Performance and Memory Issues in Unity WebGL and I encourage everyone to check it. About Brotli and jZip, these two are two different compression formats for the build in Unity. First of all, they don't ever launch uncompressed builds because they take around 11MB, the jZip, the default one, takes a little bit more space than the Brotli, so that's why we usually recommend the developers to pick the Brotli one, because you can see the difference, it may be quite small in an empty project, but when your game gets bigger, this difference will only get bigger. So yeah, usually stick with the Brotli one, although it takes a little bit more time to compress, but that's worth it.

About the exception support, so when you build a game for the web, you can pick the non-exception support, this is more performant, but you can't use try-catch anymore in your code. If you know that you have to use try-catch somewhere, pick the explicitly thrown exceptions only, which I think is also the default. And usually, you should avoid the full ones, except if you are debugging the game, because it will negatively affect the bundle size and performance of your game. I'd also like to talk about the texture compression format, which you can pick. Dext is the default one and this one is better for the desktop browsers. There is also ASTC that's better for mobile browsers and some Chromebooks. And if you pick the proper compression format, the textures don't have to be decompressed in memory and the game will use less runtime memory. You can see here in this small memory snapshot, we have a build with six textures, all of them quite big, and if they are decompressed in memory, they'll take around 75 megabytes. If they stay compressed, they take around 10 megabytes. So basically you managed to save around 65 megabytes of runtime memory, that's quite a lot on a mobile device. We tried to experiment this also with a couple of our games. Sadly, we only got some negligible load rate and load time improvements. And how we did it, we have two separate builds, and we either load the DXT one on all platforms or we smartly load this one to test on the necessary platform. And as we said, we didn't get any considerable improvements, but still, if you have, for example, a game that you launch only for mobile devices, consider to use this one, for example. Or you can check on Unity documentation how to load two separate builds, how we did with this experiment.

2. Optimizing Textures, Models, Audio, and Assets

Short description:

Pay attention to the max size of textures to reduce the build size. Consider using crunch compression for DXT and ATCM formats. Disable models that don't need to be high quality. Choose compressed memory for background audio and decompress and load for audio effects. Lower the quality of background audio to reduce the build size. Use Unity's optimization tool and build log analyzer. Consider using Asset Bundles or Unity's Addressables package to decrease initial load size. Use the Profiler and Memory Profiler tools to analyze performance and memory issues.

About the texture options. So pay attention at max size here, because you should keep this as low as possible on WebGL to reduce the final build size. If you reduce it, this will also reduce the texture size in the final build. You can also consider using crunch compression, it will help decrease also the bundle size, but it works only for these two texture compression formats, DXT and ATCM. It may take a little bit more time to build the game because the compression time will be increased, but the decompression is pretty fast when you start the game.

About the models, just in case you enabled this one, keep in mind that now the model needs to be kept in the runtime memory usage, so it's better to keep it disabled, I think by default it's also disabled. And also check if you can increase the mesh compression to high, for example, because you may have, let's say, a mountain in the distance that doesn't need to be high quality.

About the audio, if you pick compressed memory, that's usually good for background audio. It reduces the runtime memory usage, and background audios are usually some music loops that take quite a lot of memory. But this may reduce a little bit the latency and cause some imprecise audio play. Decompress and load, it's better for audio effects because you can keep them decompressed in memory. They usually don't take so much space, but they need to be precise when they're played. Also consider lowering the quality for background audio, because this may considerably reduce the audio size in the final build. Our optimization tool that you can grab on GitHub, or Unity Asset Store, and it also comes in our SDK, offers you all these tabs, they'll help you optimize your assets. It also offers build logs analyzers. For those who don't know, Unity usually generates a build log when you build a project, and it's an ugly, text-y file, log file, but this tool will beautify it a little bit and show you in a more readable way all the assets. And you can have a final look at all the assets that ended up in your final build. About Asset bundles and other symbols, consider using them because they help decrease the initial load size. How they work, they basically extract the textures, for example audio, some objects in a separate file that gets loaded only when it's needed. And you can do it with Asset Bundles which is low-level, you just fetch the file and extract the assets from it, but Unity now has an Addressables package that builds on top of Asset Bundles and it's much easier to use. You can see here an example of a game that uses Addressables and the initial build size for the build folder is around 17 megabytes. The StreamingAssets folder will be loaded later when needed, it's around 16 megabytes. So the developer managed to save around 16 megabytes from the initial game load.

I can't finish this presentation without talking a little bit about the integrated Profiler tool, which I think everyone should use to spot the performance issues and the memory issues. But for memory issues, if you want a little more detailed overview, there is a new package from Unity called Memory Profiler tool. It will help you capture snapshots of your running game, it can also connect directly to WebGL, and then it helps you analyze the textures for example of audio in the runtime memory.

That was all from my side, thank you for listening to it, and don't hesitate to check our documentation where we have more tips for Unity. And you can also contact us at developerrelations at And we're looking forward to seeing your games on

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

React Advanced Conference 2022React Advanced Conference 2022
25 min
A Guide to React Rendering Behavior
Top Content
React is a library for "rendering" UI from components, but many users find themselves confused about how React rendering actually works. What do terms like "rendering", "reconciliation", "Fibers", and "committing" actually mean? When do renders happen? How does Context affect rendering, and how do libraries like Redux cause updates? In this talk, we'll clear up the confusion and provide a solid foundation for understanding when, why, and how React renders. We'll look at: - What "rendering" actually is - How React queues renders and the standard rendering behavior - How keys and component types are used in rendering - Techniques for optimizing render performance - How context usage affects rendering behavior| - How external libraries tie into React rendering
React Summit 2023React Summit 2023
32 min
Speeding Up Your React App With Less JavaScript
Too much JavaScript is getting you down? New frameworks promising no JavaScript look interesting, but you have an existing React application to maintain. What if Qwik React is your answer for faster applications startup and better user experience? Qwik React allows you to easily turn your React application into a collection of islands, which can be SSRed and delayed hydrated, and in some instances, hydration skipped altogether. And all of this in an incremental way without a rewrite.
React Summit 2023React Summit 2023
23 min
React Concurrency, Explained
React 18! Concurrent features! You might’ve already tried the new APIs like useTransition, or you might’ve just heard of them. But do you know how React 18 achieves the performance wins it brings with itself? In this talk, let’s peek under the hood of React 18’s performance features: - How React 18 lowers the time your page stays frozen (aka TBT) - What exactly happens in the main thread when you run useTransition() - What’s the catch with the improvements (there’s no free cake!), and why Vue.js and Preact straight refused to ship anything similar
JSNation 2022JSNation 2022
21 min
The Future of Performance Tooling
Top Content
Our understanding of performance & user-experience has heavily evolved over the years. Web Developer Tooling needs to similarly evolve to make sure it is user-centric, actionable and contextual where modern experiences are concerned. In this talk, Addy will walk you through Chrome and others have been thinking about this problem and what updates they've been making to performance tools to lower the friction for building great experiences on the web.
JS GameDev Summit 2022JS GameDev Summit 2022
33 min
Building Fun Experiments with WebXR & Babylon.js
Top Content
During this session, we’ll see a couple of demos of what you can do using WebXR, with Babylon.js. From VR audio experiments, to casual gaming in VR on an arcade machine up to more serious usage to create new ways of collaboration using either AR or VR, you should have a pretty good understanding of what you can do today.
Check the article as well to see the full content including code samples: article. 

Workshops on related topic

React Summit 2023React Summit 2023
170 min
React Performance Debugging Masterclass
Featured WorkshopFree
Ivan’s first attempts at performance debugging were chaotic. He would see a slow interaction, try a random optimization, see that it didn't help, and keep trying other optimizations until he found the right one (or gave up).
Back then, Ivan didn’t know how to use performance devtools well. He would do a recording in Chrome DevTools or React Profiler, poke around it, try clicking random things, and then close it in frustration a few minutes later. Now, Ivan knows exactly where and what to look for. And in this workshop, Ivan will teach you that too.
Here’s how this is going to work. We’ll take a slow app → debug it (using tools like Chrome DevTools, React Profiler, and why-did-you-render) → pinpoint the bottleneck → and then repeat, several times more. We won’t talk about the solutions (in 90% of the cases, it’s just the ol’ regular useMemo() or memo()). But we’ll talk about everything that comes before – and learn how to analyze any React performance problem, step by step.
(Note: This workshop is best suited for engineers who are already familiar with how useMemo() and memo() work – but want to get better at using the performance tools around React. Also, we’ll be covering interaction performance, not load speed, so you won’t hear a word about Lighthouse 🤐)
JSNation 2023JSNation 2023
116 min
Make a Game With PlayCanvas in 2 Hours
Featured WorkshopFree
In this workshop, we’ll build a game using the PlayCanvas WebGL engine from start to finish. From development to publishing, we’ll cover the most crucial features such as scripting, UI creation and much more.
Table of the content:- Introduction- Intro to PlayCanvas- What we will be building- Adding a character model and animation- Making the character move with scripts- 'Fake' running- Adding obstacles- Detecting collisions- Adding a score counter- Game over and restarting- Wrap up!- Questions
Workshop levelFamiliarity with game engines and game development aspects is recommended, but not required.
JSNation 2023JSNation 2023
170 min
Building WebApps That Light Up the Internet with QwikCity
Featured WorkshopFree
Building instant-on web applications at scale have been elusive. Real-world sites need tracking, analytics, and complex user interfaces and interactions. We always start with the best intentions but end up with a less-than-ideal site.
QwikCity is a new meta-framework that allows you to build large-scale applications with constant startup-up performance. We will look at how to build a QwikCity application and what makes it unique. The workshop will show you how to set up a QwikCitp project. How routing works with layout. The demo application will fetch data and present it to the user in an editable form. And finally, how one can use authentication. All of the basic parts for any large-scale applications.
Along the way, we will also look at what makes Qwik unique, and how resumability enables constant startup performance no matter the application complexity.
JS GameDev Summit 2022JS GameDev Summit 2022
165 min
How to make amazing generative art with simple JavaScript code
Top Content
Instead of manually drawing each image like traditional art, generative artists write programs that are capable of producing a variety of results. In this workshop you will learn how to create incredible generative art using only a web browser and text editor. Starting with basic concepts and building towards advanced theory, we will cover everything you need to know.
React Day Berlin 2022React Day Berlin 2022
53 min
Next.js 13: Data Fetching Strategies
Top Content
- Introduction- Prerequisites for the workshop- Fetching strategies: fundamentals- Fetching strategies – hands-on: fetch API, cache (static VS dynamic), revalidate, suspense (parallel data fetching)- Test your build and serve it on Vercel- Future: Server components VS Client components- Workshop easter egg (unrelated to the topic, calling out accessibility)- Wrapping up
JS GameDev Summit 2022JS GameDev Summit 2022
121 min
PlayCanvas End-to-End : the quick version
Top Content
In this workshop, we’ll build a complete game using the PlayCanvas engine while learning the best practices for project management. From development to publishing, we’ll cover the most crucial features such as asset management, scripting, audio, debugging, and much more.