Web Workers handling AJAX calls - optimisation overkill?

前端 未结 5 870
温柔的废话
温柔的废话 2020-12-28 12:33

I\'m working with a code that handles all AJAX requests using Web Workers (when available). These workers do almost nothing more than XMLHttpRequest object hand

5条回答
  •  攒了一身酷
    2020-12-28 12:39

    You are optimizing your code in the wrong place.

    AJAX requests already run in a separate thread and return to the main event loop once they fulfil (and call the defined callback function).

    Web workers are an interface to threads, meant for computationally expensive operations. Just like in classical desktop applications when you don't want to block the interface with computations that take a long time.

提交回复
热议问题