# Replace deprecated browser interaction code

> Replace any deprecated code with the updated code.

Make the updates required to maintain compatibility with Unity Web builds.

Updates include replacing deprecated browser scripting code and recompiling native C/C++ plug-ins for use with WebAssembly 2023. Apply these changes to prevent unexpected behavior or broken code in your project.

## Deprecated code

The following code is deprecated and you need to replace it with the replacement code.

| Deprecated code                                           | Replacement code               |
| --------------------------------------------------------- | ------------------------------ |
| [dynCall()](#dyncall)                                     | `makeDynCall()`                |
| [Pointer\_stringify()](#pointer_stringify)                | `UTF8ToString()`               |
| [unity.Instance()](#unity-instance)                       | `CreateUnityInstance()`        |
| [gameInstance](#gameinstance)                             | `unityInstance`                |
| [MEMORY\_FILENAME and WORKER\_FILENAME](#memory_filename) | Remove references              |
| [stackTrace()](#stacktrace)                               | `new Error().stack.toString()` |

### Change dynCall to makeDynCall

The `dynCall` function is deprecated. If you have any code that uses `dynCall`, replace it with `makeDynCall`. Make this change whether you have `WebAssembly.Table` enabled or not. This update is required for compatibility with WebAssembly 2023.

For example, change:

```lang-js
dynCall('vii', callback, [1, 2])
```

to:

```lang-js
{{{ makeDynCall('vii', 'callback') }}}(1, 2)
```

#### Calling a function with no arguments

When migrating a `dynCall` that has no arguments, you must add empty parentheses () after the `makeDynCall` template to invoke the function.

For example, change:\`

```lang-js
dynCall('v', callback, []);
```

to:

```lang-js
{{{ makeDynCall('v', 'callback') }}}()
```

### Change Pointer\_stringify() to UTF8ToString

The `Pointer_stringify()` function is deprecated. If your code contains calls to `Pointer_stringify()`, replace the calls with `UTF8ToString()`.

For example, change:

```lang-js
var stringMessage = Pointer_stringify(message);
```

to:

```lang-js
var stringMessage = UTF8ToString(message);
```

### Change unity.Instance to CreateUnityInstance

`unity.Instance` is deprecated. If your code uses `unity.Instance`, use `CreateUnityInstance` instead.

For example, change:

```lang-js
var MyGameInstance = null;
  script.onload = () => {
    unity.Instance(canvas, config, (progress) => { /*...*/ }).then((unityInstance) => {
```

to:

```lang-js
var MyGameInstance = null;
  script.onload = () => {
    createUnityInstance(canvas, config, (progress) => { /*...*/ }).then((unityInstance) => {
```

### Change gameInstance to unityInstance

The `gameInstance` property is deprecated. If your code uses `gameInstance`, use `unityInstance` instead.

For example, change:

```lang-js
MyGameInstance = gameInstance;
```

to:

```lang-js
MyGameInstance = unityInstance;
```

### Remove references to MEMORY\_FILENAME and WORKER\_FILENAME

The preprocessing macros `MEMORY_FILENAME` and `WORKER_FILENAME` are obsolete and can be removed. Web page templates in previous versions of Unity used these macros to identify additional files related to the generated build.

### Change stackTrace() to new Error().stack.toString()

The global `stackTrace()` function is deprecated. Replace instances of `stackTrace()` with `new Error().stack.toString()` instead.

## Update native C/C++ plug-ins for WebAssembly 2023

Projects built with WebAssembly 2023 rely on an updated Emscripten toolchain. If you rebuild a project with WebAssembly 2023, you need to recompile any native C/C++ plug-ins with a specific set of build flags to ensure compatibility. To recompile your plug-ins, refer to [Compile native plug-ins with Emscripten](/engine/6000.7/manual/platform-specific/webgl/develop/native-plugins-with-emscripten.md#compile-plugins).

For third-party package developers, the recommended best practice is to recompile your native plug-ins to ensure they're compatible for all users building projects with WebAssembly 2023.

> **Note:**
>
> You must also [replace `dynCall` with `makeDynCall`](#dyncall) to ensure compatibility with WebAssembly 2023.

## Additional resources

* [Interaction with browser scripting](/engine/6000.7/manual/platform-specific/webgl/develop/interactingwithbrowserscripting.md)

* [Set up your JavaScript plug-in](/engine/6000.7/manual/platform-specific/webgl/develop/interactingwithbrowserscripting/web-interacting-browser-js.md)

* [Call JavaScript functions from Unity C# scripts](/engine/6000.7/manual/platform-specific/webgl/develop/interactingwithbrowserscripting/web-interacting-browser-js-to-unity.md)

* [Call Unity C# script functions from JavaScript](/engine/6000.7/manual/platform-specific/webgl/develop/interactingwithbrowserscripting/web-interacting-browser-unity-to-js.md)

* [Call C/C++/C# functions from Unity C# scripts](/engine/6000.7/manual/platform-specific/webgl/develop/interactingwithbrowserscripting/web-interacting-browsers-c-to-unity.md)
