Execute javascript function asynchronously

We have AJAX calls to access the url. Is it possible for us to run / execute JavaScript function asynchronously?

Note: setTimeout () will execute this function after a few seconds, but it will still execute synchronously.

+2


source to share


2 answers


Not. JavaScript runs in one thread per page.

You want HTML5 Web Workers . There's a good introduction to HTML5 stones.

However, the Google Gears plugin provides WorkerPool

:



API WorkerPool

The WorkerPool API allows web applications to run JavaScript code in the background without blocking the main script from executing.

There's also a suggestion from the Gears team to add this to HTML5. Strike>

+4


source


Most modern browsers implement JavaScript Web Workers, they provide an easy way to run scripts on a background thread.

Check out the following articles:



+3


source







All Articles