title: How to run javascript function in "background" / without freezing UI
body: <p>I've done an HTML form which has a lot of questions (coming from a database) in many different tabs. User then gives answers in those questions. Each time a user changes a tab my Javascript creates a save. The problem is that I have to loop through all questions each time the tab is changed and it freezes the form for about 5 seconds every time.</p>
  
  <p>I've been searching for an answer how I can run my save function in the background. Apparently there is no real way to run something in the background and many recommend using <code>setTimeout();</code> For example this one <a href="https://stackoverflow.com/questions/17204877/how-to-get-a-group-of-js-function-running-in-background">How to get a group of js function running in background</a></p>
  
  <p>But none of these examples does explain or take into consideration that even if I use something like <code>setTimeout(saveFunction, 2000);</code> it doesn't solve my problem. It only postpones it by 2 seconds in this case.</p>
  
  <p>Is there a way to solve this problem?</p>