Skip to content

Commit 4e1a8b7

Browse files
fix: improvements from recording 28.04.2025
1 parent 9238352 commit 4e1a8b7

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3989,7 +3989,7 @@ h1 {
39893989
[^104]:[CodeSandbox: HTML Performance Optimization Techniques](https://qm3w7j.csb.app/), last access: April 4, 2025.
39903990

39913991
- In this example, the `<link rel="preload">` tag is used to prioritize the loading of critical resources (CSS and JavaScript files) by indicating their importance and specifying the `as` attribute to define the resource type.
3992-
- **There is a problem with this example in CodeSandbox environment to get it fully working, it's just for your information how it should work, sorry for that. Follow [https://github.com/codesandbox/codesandbox-client/issues/8610](https://github.com/codesandbox/codesandbox-client/issues/8610) for more information.**
3992+
- **There is a problem with this example in the CodeSandbox environment. It's just for your information on how it should work to get it fully working. Sorry for that. Follow [https://github.com/codesandbox/codesandbox-client/issues/8610](https://github.com/codesandbox/codesandbox-client/issues/8610) for more details.**
39933993

39943994
##### Example: HTML Minification and Compression
39953995

@@ -4425,13 +4425,14 @@ registerServiceWorker();
44254425

44264426
[^118]CodeSandbox: Implementing Offline Capabilities with Service Workers.
44274427

4428-
[^118]:[CodeSandbox: Implementing Offline Capabilities with Service Workers](https://zjm7tx.csb.app/), last access: October 8, 2024.
4428+
[^118]:[CodeSandbox: Implementing Offline Capabilities with Service Workers](https://zjm7tx.csb.app/), last access: April 28, 2025.
44294429

44304430
- The code above demonstrates how to register a Service Worker for offline capabilities.
44314431
- First, it checks if the browser supports Service Workers.
44324432
- If supported, it registers the Service Worker script (`service-worker.js` - what the script does is outside the scope of this book) using the `register()` method.
44334433
- The Service Worker script can intercept network requests, cache assets, and manage offline behavior.
44344434
- Please turn off your internet and reload the page; it will still load, showing the offline capabilities of the Service Worker.
4435+
- - **This example has a problem in the CodeSandbox environment. To get it fully working with showcasing offline capabilities, please download the file package and run it locally from your local server. You can use the [Live Server extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer). After installing the extension, right-click `index.html` and select `Open with Live Server`. Finally, turn off your Internet, or simulate a lack of Internet via opening the DevTools, navigate to the **Network** tab, and select **"Offline"** from the dropdown menu where **"No throttling"** is chosen by default. Make sure your Service Worker has been registered.**
44354436

44364437
##### Example: Caching Assets for Offline Use
44374438

@@ -4472,12 +4473,13 @@ h1 {
44724473

44734474
[^119]CodeSandbox: Caching Assets for Offline Use.
44744475

4475-
[^119]:[CodeSandbox: Caching Assets for Offline Use](https://tmpq6w.csb.app/), last access: October 11, 2024.
4476+
[^119]:[CodeSandbox: Caching Assets for Offline Use](https://tmpq6w.csb.app/), last access: April 28, 2025.
44764477

44774478
- The code above demonstrates how to cache assets for offline use using a Service Worker.
44784479
- During the Service Worker installation phase (`install` event), it opens a cache named `v1`.
44794480
- It then adds specified URLs (including HTML, CSS, JavaScript, and image files) to the cache using the `addAll()` method, embedded in `addResourcesToCache()`.
44804481
- The cached assets can be served from the cache when the user is offline, providing offline access to the application.
4482+
- - **This example has a problem in the CodeSandbox environment. To get it fully working with showcasing offline capabilities, please download the file package and run it locally from your local server. You can use the [Live Server extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer). After installing the extension, right-click `index.html` and select `Open with Live Server`. Finally, turn off your Internet, or simulate a lack of Internet via opening the DevTools, navigate to the **Network** tab, and select **"Offline"** from the dropdown menu where **"No throttling"** is chosen by default. Make sure your Service Worker has been registered.**
44814483

44824484
##### Example: Offline Data Synchronization
44834485

@@ -4512,12 +4514,13 @@ function syncData() {
45124514

45134515
[^120]CodeSandbox: Offline Data Synchronization.
45144516

4515-
[^120]:[CodeSandbox: Offline Data Synchronization](https://tmpq6w.csb.app/), last access: October 13, 2024.
4517+
[^120]:[CodeSandbox: Offline Data Synchronization](https://5gpt4c.csb.app/), last access: April 28, 2025.
45164518

45174519
- The code above demonstrates how to perform offline data synchronization using a background sync event (`sync` event).
45184520
- The `syncMessagesLater()` asynchronous function registers a background sync from a browsing context.
45194521
- When a sync event with the tag `sync-data` is triggered, it calls the `syncData()` function.
45204522
- Developers can implement custom synchronization logic inside the `syncData()` function to synchronize data with a server or local storage.
4523+
- - **This example has a problem in the CodeSandbox environment. To get it fully working with showcasing offline capabilities, please download the file package and run it locally from your local server. You can use the [Live Server extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer). After installing the extension, right-click `index.html` and select `Open with Live Server`. Finally, turn off your Internet, or simulate a lack of Internet via opening the DevTools, navigate to the **Network** tab, and select **"Offline"** from the dropdown menu where **"No throttling"** is chosen by default. Make sure your Service Worker has been registered.**
45214524

45224525
### Conclusion: HTML5 APIs and Advanced Features
45234526

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Offline Testing and Documentation for Service Workers
2+
3+
[Learn about Service Workers](https://web.dev/learn/pwa/service-workers)
4+
5+
To simulate offline testing on your own machine, aside from disabling Wi-Fi, you can use Chrome DevTools. Open the DevTools, navigate to the **Network** tab, and select **"Offline"** from the dropdown menu where **"No throttling"** is selected by default.
74.3 KB
Binary file not shown.

__presentation-slides/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3159,7 +3159,7 @@ <h1>Welcome to My Website</h1>
31593159

31603160
#### Example: Implementing Offline Capabilities with Service Workers <!-- .slide: data-transition="zoom" data-transition-speed="slow" -->
31613161

3162-
```javascript[|1|24|1,24|26|2|23|2,23|3|21|3,21|4|9|4,9|5|6|8|6,8|7|10|12|10,12|11|13|15|13,15|14|16|18|16,18|17|20|22|20,22|21]
3162+
```javascript[|1|24|1,24|26|2|23|2,23|3|22|3,22|4|9|4,9|5|6|8|6,8|7|10|12|10,12|11|13|15|13,15|14|16|18|16,18|17|20|22|20,22|21]
31633163
const registerServiceWorker = async function () {
31643164
if ("serviceWorker" in navigator) {
31653165
try {
@@ -3240,7 +3240,7 @@ <h1>Welcome to My Website</h1>
32403240

32413241
[![Edit 120-Offline Data Synchronization](images/codesandbox.svg)](https://codesandbox.io/p/sandbox/120-offline-data-synchronization-5gpt4c)
32423242

3243-
[CodeSandbox: Offline Data Synchronization](https://tmpq6w.csb.app/).
3243+
[CodeSandbox: Offline Data Synchronization](https://5gpt4c.csb.app/).
32443244

32453245
---
32463246

@@ -3261,7 +3261,7 @@ <h1>Welcome to My Website</h1>
32613261

32623262
[![Edit 120-Offline Data Synchronization](images/codesandbox.svg)](https://codesandbox.io/p/sandbox/120-offline-data-synchronization-5gpt4c)
32633263

3264-
[CodeSandbox: Offline Data Synchronization](https://tmpq6w.csb.app/).
3264+
[CodeSandbox: Offline Data Synchronization](https://5gpt4c.csb.app/).
32653265

32663266
---
32673267

0 commit comments

Comments
 (0)