From 993cd85e4a8a886d1f8a8f1c3c5149d9422c5569 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Tue, 13 Jun 2017 14:26:00 +0200 Subject: [PATCH] Improve waiting for window.onload In case the window load event was fired before getting to the Ember initializer, it would pause app loading indefinitely. This makes sure that app loading is only paused, if there's still an event to wait for. --- app/index.html | 6 ++++++ app/initializers/defer-loading.js | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/app/index.html b/app/index.html index 37dc05a..c2635b4 100644 --- a/app/index.html +++ b/app/index.html @@ -13,6 +13,12 @@ {{content-for "head-footer"}} + + {{content-for "body"}} diff --git a/app/initializers/defer-loading.js b/app/initializers/defer-loading.js index c6e8c28..6cd1b14 100644 --- a/app/initializers/defer-loading.js +++ b/app/initializers/defer-loading.js @@ -6,9 +6,14 @@ export default { name: 'defer-loading', initialize: function(application) { + // Load event already fired, so web3 should be loaded if available + if (window.windowLoadComplete) { return true; } + + // Pause app loading application.deferReadiness(); window.addEventListener('load', function() { + // Continue app loading application.advanceReadiness(); }); }