Why does JavaScript dialog boxes (alert, confirm) stop page redrawing?

前端 未结 1 1723
时光说笑
时光说笑 2021-01-20 14:51

Opening an modal dialog box on a browser page, stops the page from redrawing. Scripts started asynchronously run uninterrupted in the background.

I illustrate the be

相关标签:
1条回答
  • 2021-01-20 15:36

    Those functions are blocking functions. Your JavaScript stops executing until they return.

    Your animations and what not in the background are not completely separated from your code calling alert(). Code that appears to be asynchronous still need to execute in the loop, and if some code blocks that loop, they will not run on their own. This is critical to proper operation of your code.

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