Does JS use OS-level non-blocking I / O to support AJAX?

If Javascript is a single threaded process and AJAX is asynchronous, then how does it go? So, at the OS level, isn't there a JS engine making the non-blocking I / O call for Ajax?

+3


source to share


1 answer


Yes, the browser engine makes a non-blocking I / O call for Ajax (when you make a non-blocking ajax call).

There are many ways a browser can implement ajax network. The only thing we know for sure is that the ajax i / o request does not block the javascript stream. And on top of that, each browser is free to implement it differently as long as they don't block the JS thread and any other threads needed to keep the browser functioning during the ajax call.



Under the skins inside the browser, it can use a separate OS thread to trigger the ajax call in a blocking way on that thread, it can use non-blocking I / O on a separate thread, this could be using non-blocking I / O on a javascript interpreter thread (probably unlikely, but possible ). It can even use a separate process to manage network operations with IPC for communication between them. Which one it chooses is entirely up to the browser implementation, as either of these methods will allow the javascript interpreter to keep running while the ajax web is happening asynchronously. It is also possible that different browsers have slightly different implementations.

Chrome, for example, uses a separate process for each browser window that other browsers don't.

+2


source







All Articles