title: Is it possible to run multiple functions side by side in javascript even if they are not triggered at the same time?
body: <p>My script runs as follows:<br></p>
  
  <pre><code>//Gets triggered when a button is clicked
  function button_1() {
      ...
      setTimeout(other_function(), 0);
      ...
  }
  
  //Checks if for hundreds of thumbnails a high-res version is available
  function other_function() {
      ...
      $.ajax({
          url: url_to_highres_file,
          type: 'HEAD',
          cache: false,
          error: function() {
              $(#output).text('The file ' + filename_of_current_file + ' is not available!');
          }
      });
      ...
  }
  </code></pre>
  
  <p>I understand that when the function "button_1" is triggered it executes code until the function "other_function" is triggered. From that point on both functions run pseudo simultaneously. The problem I have now is, that the function "other_function" runs for a long time. While that function is running and the user triggers another function e.g. "button_2", then javascript finishes the function "other_function" first before it starts executing code within the function "button_2".</p>
  
  <p>Since the function "other_function" does not have that high of a priority to the user it is more important that the website responds to input rather than finishing the function "other_function" first.</p>
  
  <p>Is there a way to still execute code blocks from the function "other_function" but also mix code blocks from the function "button_2" in between, so they run side by side and the user does not have to wait until the function "other_function" has finished?</p>
  
  <p>Thanks a lot for your help!</p>