> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.


# 分析 JavaScript 执行性能

Trace 支持录制详细的 JavaScript Profile 数据。该数据是[后台脚本](/next/zh/guide/spec.md#background-thread-scripting)的调用堆栈采样数据，对于分析后台脚本的执行性能至关重要。

### 点击 JS Profile 并选择对应的脚本引擎类型

根据后台线程脚本引擎类型选择正确的选项：

- disable：不开启；
- [primjs](/next/zh/guide/spec.md#primjs-vm)：开启 PrimJS 引擎的 Profile；
- [v8](/next/zh/guide/spec.md#v8-javascript-core-quickjs-hermes-etc)：开启 V8 引擎的 Profile。

![选择 JS Profile 类型](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/choose-js-profile-type-latest.png)
### 开始录制

点击 `Start` 按钮，开始录制 Trace 数据。

![开始录制 JS Profile](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/start-js-profile-trace-latest.png)
### 停止录制

点击 `Stop` 按钮，结束录制 Trace 数据。

![停止录制 JS Profile](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/stop-js-profile-trace-latest.png)
### 使用 sourcemap 反解 JavaScript Profile 数据（可选）

如果 scripts 被[压缩](https://rsbuild.rs/zh/config/output/minify)，可以使用 [sourcemap](/next/zh/api/build/output/source-map.md) 反解堆栈:

![反解 JavaScript Profile](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/sourcemap-decode.gif)

### 常见问题

##### 录制 Trace 后没有 JavaScript Profile 数据

- 请确保在开始录制前选择了正确的后台脚本引擎类型;
- 若使用 iOS 设备，请确保开启 Lynx DeTool 和 [PrimJS 调试开关](/next/zh/guide/start/integrate-lynx-devtool-advanced.md)。

##### 点击 SourceMap Decode 后未找到脚本

- 请确保在打开 Lynx 页面前开始录制 Trace，以确保获取脚本的名称;
