Maximum execution time for JavaScript

后端 未结 3 1253
隐瞒了意图╮
隐瞒了意图╮ 2020-12-16 02:53

I know both ie and firefox have limits for javascript execution (Source 1, Source 2). Based on number of statements executed, I heard it was 5 million somewhere in IE and ba

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-16 03:20

    The following article by Nicholas C. Zakas discusses how and when different browsers interrupt long running JavaScript code:

    • What determines that a script is long-running?

    Breaking long processing code into small chunks and launching them with timers is in fact one way to get around this problem. The following Stack Overflow post suggests a method to tackle this:

    • Show javascript execution progress

    On the other hand, web workers would be more suited for long running processing, since their execution happens in a separate process, and therefore does not block the UI thread:

    • Mozilla Dev Center: Using web workers
    • John Resig: Computing with JavaScript Web Workers
    • Nicholas C. Zakas: Experimenting with web workers

    However web workers are not supported in Internet Explorer yet, and they would not have access to the DOM.

提交回复
热议问题