Fast load times are crucial for Web-based applications, especially on mobile devices which might need to download application resources on a slow mobile network. Slow load times can result in a poor user experience and high bounce rate. Therefore, it’s important to optimize your Web build for mobile.
Web-based mobile applications work best when you have a small build and performant code because there’s less data to download, less data to store on a user’s device, and less data to load during initialization, which speeds up load times.
For Web optimizations not specific to mobile, refer to Optimize your Web build.
Use these recommended settings to make optimizations specific to Unity Web platform for mobile:
Recommendation | Description |
---|---|
Optimize for size | Disable development buildA development build includes debug symbols and enables the Profiler. More info See in Glossary settings and optimize your build for disk size (Disk Size with LTO). |
Use Brotli compression | Use the Brotli compressionA method of storing data that reduces the amount of storage space it requires. See Texture Compression, Animation Compression, Audio Compression, Build Compression. See in Glossary method to compress your Player build. |
Use the Unity Addressables system | Use the Unity Addressables system for assets. |
Optimize your audio files | Reduce the amount of disk space your audio takes up. |
Optimize the graphics in your project | Reduce the amount of disk space your graphics take up. |
Change the graphical quality level | Lower the quality level to make a faster build. |
A smaller build size is better for mobile because there’s less data to download, which usually makes load times shorter and uses less storage on the user’s device.
To make your build as small as possible, disable development build settings and optimize your build for disk size:
Go to File > Build Profiles.
Select Web.
Disable Development Build if enabled.
Set Code Optimization to Disk Size with LTO.
Note: Optimized builds with LTO can take a long time. Only use this optimization for final release or if you need to test performance. Use a faster build option during development.
For other settings that impact build size, refer to Recommended Player settings to optimize your Web build and Remove unused resources from your Web build.
If you have a script that edits settings and you want to enable the Disk Size with LTO setting with C#, add the following code to your script:
// Set Platform Settings to optimize for disk size (LTO)
UnityEditor.WebGL.UserBuildSettings.codeOptimization = UnityEditor.WebGL.WasmCodeOptimization.DiskSizeLTO;
Brotli compression is a setting where Unity pre-compresses for you while it builds. Brotli-compressed files are smaller than gzip-compressed files, which can reduce your build size.
However, Brotli takes a longer time to compress. Also, Chrome and Firefox only natively support Brotli compression over HTTPS. If that’s not suitable for your application, consider Gzip compression instead.
To use the Brotli compression setting:
Make sure your web server is configured to serve Brotli files with the correct encoding. For more details, refer to Deploy Web application.
Access the Player settings (Menu: Edit > Project Settings > Player).
Click on the Web settings tab.
Expand the Publishing Settings section.
Set Compression Format to Brotli.
If you have a project settingsA broad collection of settings which allow you to configure how Physics, Audio, Networking, Graphics, Input and many other areas of your project behave. More info
See in Glossary script and want to change the compression format with C#, add the following code to your script:
// Set the compression format to Brotli
PlayerSettings.WebGL.compressionFormat = WebGLCompressionFormat.Brotli;
Mobile browser applications need short load times to decrease user bounce rates. To keep initialization times short, instead of loading all assets at startup, use addressables to load assets only when your application needs them. Defer the loading of certain assets until after your game loads.
For these changes, make sure to update StreamingAssets/aa/catalog.json
with any new addressable files you make.
For more information about addressables and how to set them up, refer to Addressables.
To optimize your addressables further, try the following:
Sort your addressables into groups so that you reduce the number of asset bundles. The smaller the amount of asset bundles, the smaller the build size. For more information about addressable groups and how to create them, refer to Manage and create groups.
If you have a lot of audio files in your project, it’s best to compress your files to lower the size of the audio files. However compressed audio can result in lower quality audio. For information about compression formats, refer to Audio ClipA container for audio data in Unity. Unity supports mono, stereo and multichannel audio assets (up to eight channels). Unity can import .aif, .wav, .mp3, and .ogg audio file format, and .xm, .mod, .it, and .s3m tracker module formats. More info
See in Glossary.
Complex graphics can use up resources and make your build larger and less performant. But there are ways to optimize your graphics to reduce your build size and improve performance. To optimize the graphics in your build, try the following:
ASTC compressed texture types give small texture sizes and save some download time. Where ASTC isn’t supported, consider ETC2. For more information, refer to texture formatsA file format for handling textures during real-time rendering by 3D graphics hardware, such as a graphics card or mobile device. More info
See in Glossary.
To use ASTC compressed textures:
Select your texture asset in your project to open the Texture Import Settings window.
Select Web settings.
Enable Override For Web.
Set Format to one of the ASTC block options.
If you use ASTC compressed textures, try to use a larger block size for the compression. ASTC supports block sizes between 4x4 and 12x12 texels. Larger block sizes result in lower quality textures but smaller builds. For a good balance between quality and size that optimizes for download time over a mobile network, consider using 8x8. If download times are still too slow, try increasing the block size. For more information, refer to Recommended, default, and supported texture formats, by platform.
To set the block size of an ASTC compressed texture:
Select your texture asset in your project. The Texture Import Settings show.
Select Web settings.
Enable Override For Web.
Set Format to one of the larger ASTC block options, for example, RGB(A) Compressed ASTC 8x8 block.
The recommended best practice is to set the graphical quality level to the fastest option. The faster option results in a smaller build.
To change the graphical quality level:
Access the Quality settings (Menu: Edit > Project Settings > Quality).
Select the Low or Very Low quality level.
However, the fastest setting can impact the visuals of your application, so make sure that your application looks how you need it to look.
If you have a project settings script and want to change the quality level of your project in the script, add the following code:
// Set the quality level to Very Low (index 0)
QualitySettings.SetQualityLevel(0, true);
The SetQualityLevel()
function takes the index of the Quality Level matrix as a value. SetQualityLevel(0, true)
in this case is the Very Low setting, or the first option in the Quality Level matrix. To change it to Low or the second option, use SetQualityLevel(1, true)
instead.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.
When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
More information
These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising. Some 3rd party video providers do not allow video views without targeting cookies. If you are experiencing difficulty viewing a video, you will need to set your cookie preferences for targeting to yes if you wish to view videos from these providers. Unity does not control this.
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.