WasmCodeOptimization

enumeration

Description

Options for the optimization mode to use for compiling Web code.

This enum provides optimization settings for WebAssembly (Wasm) code in Unity Web builds, enabling developers to balance file size, runtime performance, and build speed depending on their needs.

using UnityEditor;

class WebOptimizer { [MenuItem("Example/Optimize For Disk Size")] static void OptimizeForDiskSize() { #if UNITY_WEBGL // Set code optimization setting to optimize for disk size UnityEditor.WebGL.UserBuildSettings.codeOptimization = UnityEditor.WebGL.WasmCodeOptimization.DiskSize; // You will find the setting applied now in File > Build Settings > Web > Web Settings #endif } }

Properties

RuntimeSpeedGenerate Web code that’s optimized for runtime performance, at the expense of taking a longer time to build compared to WasmCodeOptimization.BuildTimes.
RuntimeSpeedLTOGenerate Web code that’s optimized for runtime performance, at the expense of taking a longer time to build compared to WasmCodeOptimization.BuildTimes. Also enable an additional Link Time Optimizations (LTO) stage.
DiskSizeFavor optimizations that minimize build size, at the expense of taking a longer time to build compared to WasmCodeOptimization.BuildTimes.
DiskSizeLTOFavor optimizations that minimize build size, at the expense of taking a longer time to build compared to WasmCodeOptimization.BuildTimes. Also enable an additional Link Time Optimizations (LTO) stage.
BuildTimesGenerate Web code that takes the least amount of time to build.

Did you find this page useful? Please give it a rating: