相关疑难解决方法(0)

违规长时间运行的JavaScript任务需要xx ms

最近,我收到了这样的警告,这是我第一次得到它:

[Violation] Long running JavaScript task took 234ms
[Violation] Forced reflow while executing JavaScript took 45ms
Run Code Online (Sandbox Code Playgroud)

我正在开展一个小组项目,我不知道它来自哪里.这从未发生过.当参与该项目的其他人突然出现.如何找到导致此类警告的文件/功能?我一直在寻找答案,但主要是关于如何解决它的解决方案.如果我找不到问题的根源,我无法解决.

注意:在这种情况下,警告仅出现在chrome上.我试图使用Edge,没有得到任何类似的警告.我还没有在mozilla上测试它.

更新:我甚至得到错误jquery.min.js说:

[Violation] Handler took 231ms of runtime (50ms allowed)            jquery.min.js:2
Run Code Online (Sandbox Code Playgroud)

javascript dom google-chrome

284
推荐指数
8
解决办法
30万
查看次数

违规:“setTimeout”处理程序花费了 <N> 毫秒

该数组包含随机值,如let checkTypes = ['a','b','c'];。(数组的长度也是随机的。)

并且,数组尝试this.switch()按数组的数量调用函数。

所以,我的代码是...

for (let i = 0; i <= checkTypes.length-1; i++) {
    window.setTimeout(() => {
       this.switch(checkTypes[i]);
       if (i != 0 && i != checkTypes.length -1) window.setTimeout(() => this.switch(checkTypes[i+1]))
    });
}
Run Code Online (Sandbox Code Playgroud)

[Violation] 'setTimeout' handler took <N>ms开发者的工具控制台中仍然存在以下错误(),感觉我的代码似乎无法正常工作。

我可以更改代码以免出现此错误吗?

javascript

11
推荐指数
2
解决办法
2万
查看次数

更新到最新的Chrome后,"违规readystatechange处理程序耗时760毫秒"

更新到最新的Google Chrome版本后,当我们在我们的网站上打开彩盒时,我们会收到错误:

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.

[Violation] 'readystatechange' handler took 760ms
[Violation] Forced reflow while executing JavaScript took 51ms
[Violation] Forced reflow while executing JavaScript took 43ms
[Violation] Forced reflow while executing JavaScript took 38ms
Run Code Online (Sandbox Code Playgroud)

这种情况有时只会发生,当我们得到这些错误时,colorbox无法正常工作,Google Chrome上可能存在错误吗?

编辑:Magento合并javascript导致错误,它不能正常工作,如果我不合并他们我没有得到这些错误,它正确加载

 VM23586:4 Uncaught TypeError: Cannot set property 'value' of null  at choose (eval at <anonymous> (0a9e2e3….js:11743), <anonymous>:4:73)  at HTMLImageElement.onclick (letto-moderno-imbottito-prisma.html:1)

Uncaught TypeError: Cannot read …
Run Code Online (Sandbox Code Playgroud)

javascript google-chrome colorbox magento-1.9

8
推荐指数
1
解决办法
3万
查看次数

标签 统计

javascript ×3

google-chrome ×2

colorbox ×1

dom ×1

magento-1.9 ×1