是否可以异步重绘网站(不阻塞 UI)?

Is it possible to asynchron repaint a website (not blocking the UI)?

假设我打了一个 Ajax 电话。响应的处理程序可能是这样的:

function handleAjaxResponse(data) {
    //Do changes to the dom, wich takes 2 seconds
}

在响应到来之前,一切都很好。问题在于如何处理。

我的问题是 Internet ExplorerFirefox 的最新版本。此浏览器会阻止 UI 进程,直到 handleAjaxResponse 完全执行。 With block 我的意思是,我什么也做不了,网站挂了。

我发现 Google Chrome 没有问题。

那么有没有办法重绘文档,而不阻塞 FF 和 IE 中的 UI 进程?

将更改分解为较小的函数并将它们称为 setTimeout 回调。这样 UI 就有机会处理用户输入而不是挂起。

另请参阅:

How can I give control back (briefly) to the browser during intensive JavaScript processing?