How to break up a long running function in javascript, but keep performance

后端 未结 3 1214
借酒劲吻你
借酒劲吻你 2021-01-05 10:56

I have a long running function. Which iterates through a large array and performs a function within each loop.

longFunction : function(){
       var self =          


        
3条回答
  •  天涯浪人
    2021-01-05 11:47

    Is there anything better?

    If you’re OK with it working only in modern browsers – then you should look into “Web Workers”, that let you execute JS in the background.

    https://developer.mozilla.org/en-US/docs/DOM/Using_web_workers

提交回复
热议问题