title: Script of javascript blocks ui thread
body: <p>My js-script calculates a lot of data.
  For instance, sql.js updates my sqlite database.
  I want to create a callback with probress bar and text. But the text in html web page is always not updated until the all of my calculations be done.</p>
  
  <pre><code>$array.each(function(index){
  // CODE CODE CODE
  
          $("#pbData").text(index + ' PROGRESS');
          add_line_to_db(db,table_name,name,text);
  // CODE CODE CODE
      });
  </code></pre>
  
  <p>I tried to use something like </p>
  
  <pre><code>$array.each(function(index){
  // CODE CODE CODE
          setTimeout(function(){$("#pbData").text(index + ' PROGRESS');},1);
          add_line_to_db(db,table_name,name,text);
  // CODE CODE CODE
      });
  </code></pre>
  
  <p>But it hasn't helped.</p>
  
  <p>How to fix it?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I'm createing a sqlite database using sql.js script.
  The script loops over a table and stores the data to my database.
  A user wants to see a progress bar of table looping. So, I want to create a callback function for each iteration of sql request.</p>