---
title: "Discussion on \"[Violation] 'setTimeout' handler took <N>ms\" | Hashnode"
description: "Discussion on \"[Violation] 'setTimeout' handler took <N>ms\". 怎么解决这个东西？\n\n[Violation] Forced reflow while executing JavaScript took 38ms\n强制重绘，原因是你修改DOM的样式，立马又去读了一个Layout相关的属性，读取的话浏览器需要重新计算一遍布局，比如：\nconst openModal = () => {\n  element.style.display = 'block'; // WRITE\n  const height = element.offsetHeight; // READ..."
url: "https://hashnode.com/posts/violation-settimeout-handler-took-nms/69537759527aacd64b3fe5f6"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [\[Violation\] 'setTimeout' handler took <N>ms](https://landay.hashnode.dev/violation-settimeout-handler-took-nms?utm_source=hashnode&utm_medium=feed)

怎么解决这个东西？ \[Violation\] Forced reflow while executing JavaScript took 38ms 强制重绘，原因是你修改DOM的样式，立马又去读了一个Layout相关的属性，读取的话浏览器需要重新计算一遍布局，比如： const openModal = () => { element.style.display = 'block'; // WRITE const height = element.offsetHeight; // READ...

Dec 30, 2025 · 1 min read · landay.hashnode.dev  
Read the article

## Written by

[Landay](https://hashnode.com/@Landay)

@Landay

  
[View profile](https://hashnode.com/@Landay)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
