Version: 2023.2
Language : English
Web Build Settings
Optimize your Web build

Build your Web application

To create a build for the Web platform, go to File > Build Settings from Unity’s main menu. In the Platform list, select Web and then click Switch Platform.

For Build Settings, refer to Web Build Settings.

When you have configured the Build Settings, choose from one the following options:

  • Build: Builds your application into a Player.
  • Build and Run: Builds your application in a Player, and opens that Player on your target platform.
Build Settings Window
Build Settings Window

Build folder structure

When you build your Web application, Unity creates a Build folder with the name you specify in the Build Settings window. The Build folder has the following files, where [ExampleBuild] represents the name of the target build folder.

File name Description
[ExampleBuild].loader.js The JavaScript code that the web page needs to load the Unity content.
[ExampleBuild].framework.js JavaScript runtime and plug-insA set of code created outside of Unity that creates functionality in Unity. There are two kinds of plug-ins you can use in Unity: Managed plug-ins (managed .NET assemblies created with tools like Visual Studio) and Native plug-ins (platform-specific native code libraries). More info
See in Glossary
.
[ExampleBuild].wasm WebAssembly binary.
[ExampleBuild].mem A binary image to initialize the heap memory for your Player. Unity generates this file for multi-threaded WebAssembly builds only.
[ExampleBuild].data Asset data and ScenesA 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
.
[ExampleBuild].symbols.json Debug symbol names necessary to demangle an error stack trace. This file is only generated for Release builds when you enable the Debug Symbols option (File > Build Settings > Player Settings.)
[ExampleBuild].jpg A background image, which displays while the build is loading. This file is only generated when a Background Image is available in the Player Settings (File > Build Settings > Player Settings > Splash Image). For more information, refer to Splash Screen.

If you enable a 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
for your build, Unity identifies the extension that corresponds with the compression method and adds this extension to the names of the files inside the Build sub folder. If you enable Decompression Fallback, Unity appends the extension .unityweb to the build file names. Otherwise, Unity appends the extension .gz for the Gzip compression method, or .br for the Brotli compression method. For more information, refer to Compressed builds and server configuration.

If you enable Name Files As Hashes in the Player SettingsSettings that let you set various player-specific options for the final game built by Unity. More info
See in Glossary
, Unity uses the hash of the file content instead of the default file name. This applies to each file in the build folder. This option allows you to upload updated versions of the game builds into the same folder on the server, and only upload the files which have changed between build iterations.

Note: Opening a Player directly from the file system might not work in some browsers. This is due to security restrictions applied to local file URLs.

Enable exceptions

Use Enable Exceptions to specify how to handle unexpected code behavior (also known as errors) at runtime.

  1. To access Enable Exceptions, go to the Web Player Settings > Publishing Settings section.

  2. In the Enable Exceptions option, choose from the following options:

    • None: Select this if you don’t need any exception support. This gives the best performance and smallest builds. With this option, any exception thrown causes your content to stop with an error.

    • Explicitly Thrown Exceptions Only (default): Select this to capture exceptions which are explicitly specified from a throw statement in your scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
      See in Glossary
      and to also to make sure finally blocks are called. Note that selecting this option makes the generated JavaScript code from your scripts longer and slower; This might only be an issue if scripts are the main bottleneck in your project.

    • Full Without Stacktrace: Select this option to capture:

      • Exceptions which are explicitly specified from throw statements in your scripts (the same as in the Explicitly Thrown Exceptions Only option)
      • Null References
      • Out of Bounds Array accesses
    • Full With Stacktrace: This option is similar to the earlier option, but it also captures Stack traces. Unity generates these exceptions by embedding checks for them in the code, so this option decreases performance and increases browser memory usage. Only use this for debugging, and always test in a 64-bit browser.

Additional resources

Web Build Settings
Optimize your Web build