Remote Start

Remote application start

Remote application start

In order to "pause" application initialization prior to perform some asynchorous task, the following approach can be used with the help of EJS partials:

head.ejs

<script>
  function startApplication() {
    if (!window.runApplication) {
      window.onApplicationPrepared = function() {
        window.runApplication();
      }
    } else {
      window.runApplication();
    }
  }

  (function() {
    window.DISABLE_AUTOLOAD = true;

    // Performing some request needed
    return fetch('https://example.com')
      .then(response => response.json())
      .then(data => {
        // Make something with data, e.g. put to global variables

        startApplication();
      })
      .catch(() => {
        startApplication();
      });
  })();
</script>