-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Romain Racamier
committed
Jun 24, 2019
1 parent
a71c707
commit 7353c34
Showing
3 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Credit : https://developers.google.com/speed/docs/insights/OptimizeCSSDelivery | ||
|
||
const loadDeferredStyles = () => { | ||
const addStylesNode = document.getElementById('deferred-styles') | ||
const replacement = document.createElement('div') | ||
replacement.innerHTML = addStylesNode.textContent | ||
document.body.appendChild(replacement) | ||
addStylesNode.parentElement.removeChild(addStylesNode) | ||
} | ||
|
||
const raf = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame | ||
|
||
if (raf) { | ||
raf(() => window.setTimeout(loadDeferredStyles, 0)) | ||
} else { | ||
window.addEventListener('load', loadDeferredStyles) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import './defer-styles' | ||
import './register-sw' | ||
|
||
console.log('folio started') |