# 闪烁现象及应对方法

## 闪烁现象及应对方法

## 什么是闪烁现象

闪烁现象是指页面打开时，瞬间显示修改前的内容，然后显示修改后的内容的现象。进行AB测试或重定向测试时，容易发生闪烁。

## 如何缓解闪烁现象

#### Step1：安装Ptengine基础标签

Ptengine基础标签内包含了防闪烁功能的逻辑。 因此，我们建议在页面head内早期安装它，以便及时发挥作用。

#### Step2：在Ptengine管理画面中的设置

**1. 什么是防闪烁功能**

这是一项缓解闪烁现象的功能。

在Ptengine experience的体验设置画面中，可以设置防闪烁功能的"开/关"。

此功能默认为关闭状态，但启用时会通过白屏隐藏闪烁现象。

**2. 在哪些情况下应该启用防闪烁功能**

【速查表】推荐设置总结

> **WARNING** **注意**：如果同一页面上发布了多个体验，只要其中一个体验启用了防闪烁设置，该页面就会发挥防止闪烁的效果。

### 无法在head中直接放置Ptengine标签的情况

#### 1. 现象和原因

通过GTM（Google Tag Manager）进行安装，或在HTML的`<body>`内安装基础标签时，防闪烁功能可能无法正常工作。

这是因为优先考虑页面显示速度的"异步加载"导致Ptengine标签的执行延迟。

结果是，出现"原始页面→白屏→编辑后的页面"这样不自然的显示，可能会损害用户体验。

#### 2. 解决方法

要解决此问题，**保持现有的基础标签不变**，按以下步骤**添加专用的防闪烁标签**。

**① 在`<head>`中安装专用标签**

在网站HTML源代码的`<head>`内直接放置以下防闪烁专用标签。

`<script src="https://js.ptengine.com/xxxxxxxx_antiFlicker.js" ></script>`

> **WARNING** ※注意：xxxxxxxx是项目ID，与基础标签的ID一致。

**② 在Ptengine端启用功能**

在Ptengine管理画面中，将防闪烁功能设置为"On"。

> **WARNING** **注意事项**
>
> 防闪烁标签的超时时间为**4秒**。
>
> 如果页面加载速度本身极其缓慢，即使进行上述设置，也可能发生闪烁。

因此，我们建议尽可能在head中直接放置Ptengine标签。

## 总结

防止闪烁的设置因标签安装方法而异。

**推荐：** **在`<head>`内直接安装的情况下**，安装Ptengine的**基础标签**，将防闪烁功能设置为**ON**。

**通过GTM等进行安装的情况：** 将**防闪烁专用标签**额外安装在`<head>`内，将防闪烁功能设置为**ON**。

请在以下表格中确认各自设置和效果的详细信息。

※如果直接安装基础标签，则无需额外安装防闪烁标签。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://helps.ptengine.com/cn/faq/experience-edit/anti-flicker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
