Skip to content
This repository was archived by the owner on Sep 10, 2022. It is now read-only.

Commit a10574e

Browse files
author
Matt Gaunt
committed
Minor tweaks to readme and layouts / views
1 parent b505274 commit a10574e

File tree

7 files changed

+33
-20
lines changed

7 files changed

+33
-20
lines changed

README.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Service Worker Application Shell architecture
22

3-
A sample web app shell demonstrating a shell + content architecture using [Service Worker](http://www.html5rocks.com/en/tutorials/service-worker/introduction/). This allows you to offline your 'shell', gaining performance advantages.
3+
A sample web app shell demonstrating a shell + content architecture using [Service Worker](http://www.html5rocks.com/en/tutorials/service-worker/introduction/). This allows you to offline your 'shell', gaining performance advantages.
44

55
## Goals
66

@@ -24,19 +24,26 @@ $ npm install -g gulp nodemon && npm install
2424

2525
## Usage
2626

27-
### Build
27+
### Production Build
2828

2929
```sh
3030
$ gulp
3131
```
3232

33-
### Serve/watch
33+
### Development Build with Watch
3434

3535
```sh
36-
$ nodemon server/app.js && gulp dev
36+
$ gulp dev
3737
```
3838

39-
You will need to use AppEngine to serve the contents of the directory.
39+
### Serve/watch
40+
41+
Once you've got a production build or development build of gulp done, start the
42+
server with:
43+
44+
```sh
45+
$ nodemon server/app.js
46+
```
4047

4148
## Why?
4249

@@ -48,16 +55,16 @@ We can offline cache our application shell without the network being present and
4855

4956
During the first load experience, our goal is to get meaningful content to the user’s screen as quickly as possible. To achieve this:
5057

51-
* **Server** will send down HTML content the client can render and will use far-future HTTP cache expiration headers to account for browsers without Service Worker support. It will serve filenames using hashes to enable ‘versioning’ and easy updates for later on in the application lifecycle.
52-
* **Page(s)** will include inline CSS styles in the document <head> to provide a fast first paint of the application shell. Each page will asynchronously load in the JavaScript necessary for the current view. As CSS cannot be asynchronously loaded in natively, this can be emulated using JavaScript (or something like the Filament Group’s [loadCSS](https://github.com/filamentgroup/loadCSS) project).
53-
* **Service Worker** will store a cached entry of the application shell so that on repeat visits, the shell can be loaded entirely from the SW cache unless an update is available on the network.
58+
* **Server** will send down HTML content the client can render and will use far-future HTTP cache expiration headers to account for browsers without Service Worker support. It will serve filenames using hashes to enable ‘versioning’ and easy updates for later on in the application lifecycle.
59+
* **Page(s)** will include inline CSS styles in the document <head> to provide a fast first paint of the application shell. Each page will asynchronously load in the JavaScript necessary for the current view. As CSS cannot be asynchronously loaded in natively, this can be emulated using JavaScript (or something like the Filament Group’s [loadCSS](https://github.com/filamentgroup/loadCSS) project).
60+
* **Service Worker** will store a cached entry of the application shell so that on repeat visits, the shell can be loaded entirely from the SW cache unless an update is available on the network.
5461

5562
In the background, we will register our Service Worker following this lifecycle:
5663

57-
| Event | Action |
64+
| Event | Action |
5865
|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
59-
| Install | Cache application shell and other SPA resources |
60-
| Activate | Clear out old caches |
66+
| Install | Cache application shell and other SPA resources |
67+
| Activate | Clear out old caches |
6168
| Fetch | Serve up single page web app for urls.progressively cache future content - unless it’s no-cache header. Cache in a ‘content-cache’ to separate from the web app |
6269

6370
#### File revision
@@ -78,9 +85,9 @@ should handle the concerns around file revisions, the install/activate questions
7885

7986
## Tips for your application shell
8087

81-
In a [Progressive webapp](https://infrequently.org/2015/06/progressive-apps-escaping-tabs-without-losing-our-soul/), everything necessary to load the the simplest "shell" of your UI consists of HTML, CSS and JavaScript. Keep this shell as lean as possible. Some of the will come from your application’s index file (inline DOM, styles) and the rest may be loaded from external scripts and stylesheets. Together, they are all you need to display a simple, static app. It’s important to keep the shell of your webapp learn to ensure that some inline static structural content can be displayed as soon as the webapp is opened, regardless of the network being available or not.
88+
In a [Progressive webapp](https://infrequently.org/2015/06/progressive-apps-escaping-tabs-without-losing-our-soul/), everything necessary to load the the simplest "shell" of your UI consists of HTML, CSS and JavaScript. Keep this shell as lean as possible. Some of the will come from your application’s index file (inline DOM, styles) and the rest may be loaded from external scripts and stylesheets. Together, they are all you need to display a simple, static app. It’s important to keep the shell of your webapp learn to ensure that some inline static structural content can be displayed as soon as the webapp is opened, regardless of the network being available or not.
8289

83-
A static webapp that always displays the same content may not be what your users expect - it may well be quite dynamic. This means the app may need to fetch data specific to the user’s current needs so this data can come from the network / a server-side API but we logically separate this work for our app from the application shell. When it comes to offline support, structuring your app so that there’s a clear distinction between the page shell and the dynamic or state-specific resources will come in very handy.
90+
A static webapp that always displays the same content may not be what your users expect - it may well be quite dynamic. This means the app may need to fetch data specific to the user’s current needs so this data can come from the network / a server-side API but we logically separate this work for our app from the application shell. When it comes to offline support, structuring your app so that there’s a clear distinction between the page shell and the dynamic or state-specific resources will come in very handy.
8491

8592
## License
8693

server/layouts/app-shell.handlebars

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ limitations under the License.
4343
</header>
4444

4545
<!-- Main Content goes here -->
46-
<main class="main js-global-main" aria-role="main"></main>
46+
<main class="main js-global-main" aria-role="main">
47+
48+
</main>
4749

4850
<!-- Navigation Drawer -->
4951
<section class="side-nav js-side-nav">

server/layouts/default.handlebars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ limitations under the License.
3838
Toggle nav menu
3939
</button>
4040

41-
<h1 class="header__title">Static Page</h1>
41+
<h1 class="header__title">App Shell</h1>
4242
</header>
4343

4444
<main class="main js-main" aria-role="main">

server/layouts/partial.handlebars

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<style type="text/css">{{{inlineStyles}}}</style>
22

3-
<div class="card">
43
{{{ body }}}
5-
<div>
64

75
{{#each remoteScripts}}
86
<script src="{{this}}" async></script>

server/views/index.handlebars

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
<h1>Index</h1>
1+
<div class="card">
2+
<h1>Index</h1>
3+
</div>

server/views/url-1.handlebars

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
<h1>URL 1</h1>
1+
<div class="card">
2+
<h1>URL 1</h1>
3+
</div>

server/views/url-2.handlebars

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
<h1>URL 2</h1>
1+
<div class="card">
2+
<h1>URL 2</h1>
3+
</div>

0 commit comments

Comments
 (0)