Skip to content

Commit 9df62f0

Browse files
committed
Updated comments with new setting. Rebuilt files.
1 parent 7c59bb7 commit 9df62f0

File tree

4 files changed

+41
-9
lines changed

4 files changed

+41
-9
lines changed

dist/upup.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/upup.zip

0 Bytes
Binary file not shown.

docs/README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,21 @@ UpUp can only serve offline content for requests within its scope. The scope is
2929

3030
This means that if you placed the files in your `/js/` directory, UpUp will only be able to show your offline content when users try to look inside the `/js/` directory.
3131

32-
**This is why you should always place the script as close to the root of your site as possible (e.g. https://www.talater.com/upup.min.js).**
32+
**This is why you should almost always place the script as close to the root of your site as possible (e.g. https://www.talater.com/upup.min.js).**
33+
34+
#### Scope - Advanced
35+
It is possible to keep `upup.min.js` outside the scope (e.g. in a CDN), as long as `upup.sw.min.js` is kept local (that file's location determines the scope).
36+
If you choose to keep the two in separate directories, make sure to pass the `service-worker-url` [setting](https://github.com/TalAter/UpUp/tree/master/docs#settings).
37+
````html
38+
<script src="//cdnjs.cloudflare.com/ajax/libs/UpUp/0.1.0/upup.min.js"></script>
39+
<script>
40+
UpUp.start({
41+
'content-url': 'offline.html',
42+
'assets': ['/img/logo.png', '/css/style.css', 'headlines.json'],
43+
'service-worker-url': '/upup.sw.min.js'
44+
});
45+
</script>
46+
````
3347

3448
## Settings
3549

@@ -45,9 +59,11 @@ same settings object directly to the start() method.
4559
UpUp.start({ content: 'Cannot reach site. Please check your internet connection.' });
4660

4761
The settings object supports the following options:
48-
- `content-url` (String) The content to display when user is offline (url to the content that will be served)
49-
- `content` (String) The content to display when user is offline (plain text, HTML, etc.)
50-
- `assets` (Array) Array of assets to cache for offline access
62+
- `content-url` (String) The content to display when user is offline (url to the content that will be served)
63+
- `content` (String) The content to display when user is offline (plain text, HTML, etc.)
64+
- `assets` (Array) Array of assets to cache for offline access
65+
- `service-worker-url` (String) The url to the service worker file (`upup.sw.min.js`)
66+
Allows loading `upup.min.js` from a CDN while `upup.sw.min.js` stays local (see [scope](https://github.com/TalAter/UpUp/blob/master/docs/README.md#scope))
5167

5268
# API Reference
5369

src/upup.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,21 @@
3535
*
3636
* This means that if you placed the files in your `/js/` directory, UpUp will only be able to show your offline content when users try to look inside the `/js/` directory.
3737
*
38-
* **This is why you should always place the script as close to the root of your site as possible (e.g. https://www.talater.com/upup.min.js).**
38+
* **This is why you should almost always place the script as close to the root of your site as possible (e.g. https://www.talater.com/upup.min.js).**
39+
*
40+
* #### Scope - Advanced
41+
* It is possible to keep `upup.min.js` outside the scope (e.g. in a CDN), as long as `upup.sw.min.js` is kept local (that file's location determines the scope).
42+
* If you choose to keep the two in separate directories, make sure to pass the `service-worker-url` [setting](https://github.com/TalAter/UpUp/tree/master/docs#settings).
43+
* ````html
44+
* <script src="//cdnjs.cloudflare.com/ajax/libs/UpUp/0.1.0/upup.min.js"></script>
45+
* <script>
46+
* UpUp.start({
47+
* 'content-url': 'offline.html',
48+
* 'assets': ['/img/logo.png', '/css/style.css', 'headlines.json'],
49+
* 'service-worker-url': '/upup.sw.min.js'
50+
* });
51+
* </script>
52+
* ````
3953
*
4054
* ## Settings
4155
*
@@ -52,9 +66,11 @@
5266
*
5367
*
5468
* The settings object supports the following options:
55-
* - `content-url` (String) The content to display when user is offline (url to the content that will be served)
56-
* - `content` (String) The content to display when user is offline (plain text, HTML, etc.)
57-
* - `assets` (Array) Array of assets to cache for offline access
69+
* - `content-url` (String) The content to display when user is offline (url to the content that will be served)
70+
* - `content` (String) The content to display when user is offline (plain text, HTML, etc.)
71+
* - `assets` (Array) Array of assets to cache for offline access
72+
* - `service-worker-url` (String) The url to the service worker file (`upup.sw.min.js`)
73+
* Allows loading `upup.min.js` from a CDN while `upup.sw.min.js` stays local (see [scope](https://github.com/TalAter/UpUp/blob/master/docs/README.md#scope))
5874
*
5975
* # API Reference
6076
*/

0 commit comments

Comments
 (0)