“Violation readystatechange handler took 760ms”在更新Chrome后出现的问题。

13

更新后Google Chrome v57.0.2987,打开Collorbox时我们的网站出现错误:

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

这种情况有时会发生。 当我们遇到这些错误时,Colorbox无法为我们工作。

Google Chrome上可能有bug吗?

编辑: 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 property 'close' of undefined  at HTMLDivElement.onclick (letto-moderno-imbottito-prisma.html:1)

它在最近的Chrome更新之前是可以正常工作的,所以我猜测可能是Colorbox请求过于繁重了? - LaurenFrida
同步调用不好。 - epascarello
1
这似乎是一个重复的问题: https://dev59.com/5FgR5IYBdhLWcg3whtmk#41218580 - oklas
1个回答

34

1
我曾经遇到过同样的问题。在点击按钮时,我通过弹出窗口向用户发出警告,并且弹出窗口会一直停留在那里,直到用户点击“确定”。我将alert函数调用更改为console.log,现在就没问题了。 - Yigit Alparslan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接