> 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.

# deprecated InitContainerEntry

:::warning
该事件在 Lynx SDK 3.7 版本已废弃，相关数据可从 [`LoadBundleEntry`](/next/zh/api/lynx-api/performance-api/performance-entry/load-bundle-entry.md) / [`ReloadBundleEntry`](/next/zh/api/lynx-api/performance-api/performance-entry/reload-bundle-entry.md) 中获取.
:::

APISummary
`InitContainerEntry` 接口提供了 Lynx 页面显示前[容器](/next/zh/guide/spec.md#container)准备工作的关键时间点，它继承自 [`PerformanceEntry`](/next/zh/api/lynx-api/performance-api/performance-entry.md)。

在初始化流程中，指标的定义如下图：
![container 初始化的关键时间](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/lynx-website/assets/doc/init-container-entry.png)

:::info
该事件内的时间戳依赖容器通过 [`LynxView.setExtraTiming`](/next/zh/api/lynx-native-api/lynx-view/set-extra-timing.md) 提供。
:::

## 示例

该示例展示了如何获取 `InitContainerEntry`。

**下面是一个示例: performance-api**

**Entry:** `src/init-container-entry`
**Bundle:** `dist/init-container-entry.lynx.bundle`

```tsx {10-22}
import * as React from "@lynx-js/react";
import { root, useMemo, useState } from "@lynx-js/react";
import type { InitContainerEntry, PerformanceEntry } from "@lynx-js/types";
import "./index.css";

export default function InitContainerEntryExample(this: any) {
  const [initContainerEntry, setInitContainerEntry] = useState<string>("");

  function observerPerformanceEntry() {
    "background-only";
    // 1. Create a performance observer.
    const observer = lynx.performance.createObserver((entry: PerformanceEntry) => {
      console.log(JSON.stringify(entry));
      if (entry.entryType == "init" && entry.name == "container") {
        // 3. Received "init.container" event.
        const initContainerEntry = entry as InitContainerEntry;
        setInitContainerEntry(JSON.stringify(initContainerEntry, null, 4));
        observer.disconnect();
      }
    });
    // 2. register to listen to the "init.container" event.
    observer.observe(["init.container"]);
  }

  useMemo(() => {
    observerPerformanceEntry();
  }, []);

  return (
    <view className="container">
      <text className="title">Hello InitContainerEntry~</text>
      <text className="entry">{initContainerEntry}</text>
    </view>
  );
}

root.render(<InitContainerEntryExample />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.8.0



## 实例属性

### [entryType](/next/zh/api/lynx-api/performance-api/performance-entry.md#entrytype)

```tsx
entryType: string;
```

性能事件的类型，当前类所有实例的值均固定为 `init`。

### [name](/next/zh/api/lynx-api/performance-api/performance-entry.md#name)

```tsx
name: string;
```

性能事件的名称，当前类所有实例的值均固定为 `container`。

### openTime

```tsx
openTime: number;
```

容器开始打开 Lynx 页面的时间。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### containerInitStart

```tsx
containerInitStart: number;
```

容器初始化开始的时间。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### containerInitEnd

```tsx
containerInitEnd: number;
```

容器初始化完毕的时间。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### prepareTemplateStart

```tsx
prepareTemplateStart: number;
```

容器开始准备 [TemplateBundle](/next/zh/guide/spec.md#app-bundle-aka-template-bundle) 的时间。“准备”指容器通过网络下载、加载本地缓存等任意方式获得 TemplateBundle。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

### prepareTemplateEnd

```tsx
prepareTemplateEnd: number;
```

容器准备完 [TemplateBundle](/next/zh/guide/spec.md#app-bundle-aka-template-bundle) 的时间。“准备”指容器通过通过网络下载、加载本地缓存等任意方式获得 TemplateBundle。该时间戳是一个表示为浮点型的 Unix 时间戳（单位：毫秒），精确到小数点后三位。例如：1739594612307.429。

## 兼容性

**Compatibility Table**

**Query:** `lynx-api.performance-api.performance-entry.init-container-entry`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/performance-api/performance-entry/init-container-entry.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| init-container-entry | Yes (3.1) | Yes (3.4) | Yes (3.1) | Yes (3.7) | Yes (3.7) | No |

