Force DOM refresh in JavaScript

前端 未结 1 341
天涯浪人
天涯浪人 2021-01-13 19:40

I am running a loop within a click event handler doing the following:

  • run heavy computation (takes 1-3s)
  • call $(\"
  • + data +
相关标签:
1条回答
  • 2021-01-13 20:17

    If you are in a browser that supports it, workers are ideal for this situation.

    If not, use setTimeout after each computation to break the callstack and allow the browser to use time on rendering.

    0 讨论(0)
提交回复
热议问题