Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • What is a Web Worker?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 108
    Comment on it

    Hi all,

    Below is a short description of web workers.

    What is a Web Worker?

    Web worker is JavaScript which runs in backside without affecting the performance of site and it is independent of other the scripts,.

    what web worker are for ?

    For this lets consider the below example -

    function  testFunction(){
        for (i = 0; i < 10000000000000; i++)
        {
           x = i + x;
        }
    } 
    


    <input type="button" onclick="testFunction();" /> 
    

    by the above loop, code will execute on button click, so now this execution is synchronous. It means the complete browser will wait until the for loop complete.

    It can freezed and unresponsive the browser with an error message.

    So if we move this loop (a heavy loop) in a JavaScript file and run, then the browser have no need to wait for the loop. Hence, Now we have a more responsive browser. Thats what web worker are for.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: