Skip to content

Commit

Permalink
delay style loading (#29)
Browse files Browse the repository at this point in the history
* inline assets
  • Loading branch information
Shuunen authored Jun 25, 2019
1 parent ee0688f commit 050c1f8
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 15 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cSpell.words": [
"GTmetrix",
"nosniff",
"purgecss",
"sourcerer"
]
Expand Down
20 changes: 13 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@
"author": "Romain Racamier-Lafon <romain.racamier@gmail.com>",
"bugs": "https://github.com/Shuunen/folio/issues",
"config": {
"lh-port": 8088,
"port": 8080
},
"dependencies": {
"cross-var": "1.1.0",
"google-lighthouse-puppeteer": "0.5.2",
"http-server": "0.11.1",
"npm-run-all": "4.1.5",
"parcel-bundler": "1.12.3",
"parcel-plugin-inliner": "1.0.10",
"parcel-plugin-purgecss": "2.1.2",
"parcel-plugin-static-files-copy": "2.1.2",
"parcel-plugin-sw-precache": "1.1.1"
"parcel-plugin-sw-precache": "1.1.1",
"repo-check": "1.1.4",
"rimraf": "2.6.3",
"serve": "11.0.2"
},
"description": "My personal portfolio",
"devDependencies": {
Expand All @@ -22,7 +26,6 @@
"src/",
"static/"
],
"private": true,
"homepage": "https://github.com/Shuunen/folio#readme",
"keywords": [
"Romain Racamier-Lafon",
Expand All @@ -33,20 +36,23 @@
],
"license": "GPL-3.0",
"name": "folio",
"private": true,
"repository": {
"type": "git",
"url": "git+https://github.com/Shuunen/folio.git"
},
"scripts": {
"build": "parcel build src/index.html --public-url . --no-source-maps",
"check": "npx repo-check",
"check": "repo-check",
"dev": "cross-var parcel src/index.html --port $npm_package_config_port",
"lint": "standard \"src/**/*.js\" \"tests/**/*.js\" --fix",
"prebuild": "npx rimraf dist/*",
"postbuild": "rimraf dist/{*.css,main.*.js}",
"prebuild": "rimraf dist/*",
"prestart": "npm run build",
"serve": "cross-var http-server dist -p $npm_package_config_port",
"serve": "cross-var serve dist --listen $npm_package_config_port --single",
"serve:lh": "cross-var serve dist --listen $npm_package_config_lh_port --single",
"start": "npm run serve",
"test": "npm-run-all check lint build --parallel serve test:lh --race",
"test": "npm-run-all check lint build --parallel serve:lh test:lh --race",
"test:lh": "run-s test:lh:generate-report test:lh:check-metrics",
"test:lh:check-metrics": "node tests/check.js",
"test:lh:generate-report": "lighthouse-puppeteer --file ../../tests/puppeteer.js --output_directory tests/reports"
Expand Down
5 changes: 3 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ <h1 class="fz30">Hey I'm Romain Racamier-Lafon</h1>
<a target="_blank" rel="noopener noreferrer" href="https://vuejs.org">VueJS</a>,
<a target="_blank" rel="noopener noreferrer" href="https://gtmetrix.com/reports/rrl-folio.netlify.com/souu1lie">performance</a>
and
<a target="_blank" rel="noopener noreferrer" href="https://lighthouse-dot-webdotdevsite.appspot.com/lh/html?url=https://rrl-folio.netlify.com/">best practices.</a>
<a target="_blank" rel="noopener noreferrer"
href="https://lighthouse-dot-webdotdevsite.appspot.com/lh/html?url=rrl-folio.netlify.com/">best practices.</a>
</p>
<p>
You can check my
Expand All @@ -39,7 +40,7 @@ <h1 class="fz30">Hey I'm Romain Racamier-Lafon</h1>
if you dare.
</p>
</main>
<script nonce="shuu6162n1" async src="main.js"></script>
<script nonce="shu6162n1" async src="main.js"></script>
</body>

</html>
2 changes: 1 addition & 1 deletion src/register-sw.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Activate the service worker
if ('serviceWorker' in navigator && document.location.hostname !== 'localhost') {
if ('serviceWorker' in navigator && document.location.port !== '8080') {
window.addEventListener('load', function () {
// this way Parcel won't look for service-worker.js file
const swName = 'service-worker.js'
Expand Down
4 changes: 4 additions & 0 deletions src/styles/_base.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ a {
text-decoration: none;
}

p {
line-height: 2.5rem;
}

strong {
color: var(--color-primary);
}
Expand Down
2 changes: 1 addition & 1 deletion static/_headers
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Cache-Control: public, max-age=31536000
Content-Security-Policy: script-src 'self' 'strict-dynamic' 'nonce-shuu6162n1' 'unsafe-inline' http: https:; object-src 'none'; base-uri 'self';
Content-Security-Policy: script-src 'self' 'strict-dynamic' 'nonce-shu6162n1' 'unsafe-inline' http: https:; object-src 'none'; base-uri 'self';
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
6 changes: 3 additions & 3 deletions tests/check.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const assert = require('assert')
const data = require('./reports/summary.json')
const score = parseFloat(data[0].score) * 100
const lastScore = 95
const minScore = 90

assert(score >= lastScore, `Lighthouse current score is ${score} and should be superior or equal to last one : ${lastScore}`)
assert(score >= minScore, `Lighthouse current score is ${score} and should be superior or equal to the minimal one : ${minScore}`)

console.log(`\n\nGood ! Lighthouse current score (${score}) is not worse than last one (${lastScore}) \\o/\n`)
console.log(`\n\nGood ! Lighthouse current score (${score}) is great \\o/\n`)
2 changes: 1 addition & 1 deletion tests/puppeteer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Puppeteer {
getUrls () {
return [
'http://127.0.0.1:8080'
'http://localhost:8088'
]
}

Expand Down

0 comments on commit 050c1f8

Please sign in to comment.