Version: 2022.3
Language : English
Use C# code to enable optimization settings
Optimize WebGL platform for mobile

Remove unused resources from your WebGL build

Remove unused packages and shadersA program that runs on the GPU. More info
See in Glossary
from a project to make the build smaller. A smaller build reduces application load times and improves the performance of your application.

Remove or disable unused packages

Unused packages might affect the final output size of the build. Remove or disable all packages the project doesn’t use. This includes built-in packagesBuilt-in packages allow users to toggle Unity features on or off through the Package Manager. Enabling or disabling a package reduces the run-time build size. For example, most projects don’t use the legacy Particle System. By removing the abstracted package of this feature, the related code and resources are not part of the final built product. Typically, these packages contain only the package manifest and are bundled with Unity (rather than available on the package registry).
See in Glossary
and packages enabled by default, such as the Input System package, which can double the build size if it’s not removed.

To remove a package, refer to Remove a UPM package from a project.

To disable a built-in package, refer to Disable a built-in package.

Remove unused shader variants

Enable shader stripping to remove shader variants that aren’t used in a sceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary
. Shader stripping can reduce your build file size.

Important: Test your application to make sure your unused shaders aren’t referenced by other shaders.

To enable shader stripping, refer to Graphics.

Additional resources

Use C# code to enable optimization settings
Optimize WebGL platform for mobile