title: wait for Promise.all in a synchronous function, basically blocking! javascript
body: <p>I have alot of syncrhounous functions that i want to execute before that are basic ajax requests, these request will render html to the DOM. </p>
  
  <p>In order to do this i had to execute all of this synchrounous 
  requests one by one. But i somehow want to these synchrounous functions asynchrounous all at the same time and wait for them to finnish in order to speed things up. This has to happen inside a synchrounous function. But my understanding is that this doesnt work in javascript, but i would like to hear what you guys have to say.</p>
  
  <p>So my attempt was to add all of these synchrounous requests into asynchrounous promises and then do a Promise.all call. I cant wait for the promise.all().then because the main thread will keep on execute the rest of the code after this main synchrounous thread/function. So i wonder if there is a way to block the main thread in order to wait for these asynchrounous calls</p>
  
  <p>heres a short illustration of what im talking about</p>
  
  <pre><code>var syncfunc = () =&gt; {
  var getPromise = () =&gt; {
      return new Promise((resolve) =&gt; {
          var asyncAjaxRequest = async function() {
              doSomeStuff();
              resolve();
          }
      })
  }
  var promises = [getPromse(), getPromse(), getPromse()];
  
  
  Promise.all(promises);
  
  console.log('i want this console.log to execute after all promises executed doSomeStuff');
  
  /**
   * 
   * Promise.all(promises).then(() =&gt; {
          // I cant use this, because its script in other files that will execute if i wait like this
      })
   */
  }
  </code></pre>
  
  <p>I know .then will execute when all resolves are done, but i basiacally want  to block this synchrounous thread waiting for all other asynchrounous to finish. </p>
  
  <p>If i could i would ofcourse change the structure into my needs, but the problem and the reason why im trying to do this is because im using sitevision framework, and want to add some content to the dom before a print module opens the print window. To call every function synchrounous is just not the way to go, its to slow. Ive also tried to set window.print = null to make the print function disabled, and then add the print function back when promises resolves, but it simply doesnt work</p>