From 4d37790c6d457f5f9dcee6b297dd98b216a87472 Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Mon, 9 Oct 2017 15:33:50 +0300 Subject: [PATCH] Font handling: let's use FOUT with FontFaceObserver Check if Promise is available --- public/500.html | 19 +++++++++++- public/index.html | 67 +++++++++++++++++++++++++++++++++++++++- src/marketplaceIndex.css | 13 ++++++-- 3 files changed, 95 insertions(+), 4 deletions(-) diff --git a/public/500.html b/public/500.html index 46defe6d..f970652e 100644 --- a/public/500.html +++ b/public/500.html @@ -160,6 +160,17 @@ } +
@@ -175,8 +186,14 @@ // Browsers that don't support FontFaceSet, will show only system fonts if (document.fonts) { + // Check if Promise exists in window + var hasFeaturePromise = typeof window.Promise !== 'undefined' && + typeof window.Promise.reject !== 'undefined' && + Object.prototype.toString.call(Promise.resolve()) === '[object Promise]'; + // Optimization for Repeated views - i.e. page refresh hits the same error - if (sessionStorage.fontsLoaded) { + // If there's no Promise available, we also revert to @font-face loading + if (sessionStorage.fontsLoaded || !hasFeaturePromise) { document.getElementById("body").classList.add("fontsLoaded"); return; } diff --git a/public/index.html b/public/index.html index 5ca08a00..09c66315 100644 --- a/public/index.html +++ b/public/index.html @@ -62,11 +62,76 @@ } + - +
+ +