You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-4Lines changed: 7 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3989,7 +3989,7 @@ h1 {
3989
3989
[^104]:[CodeSandbox: HTML Performance Optimization Techniques](https://qm3w7j.csb.app/), last access: April 4, 2025.
3990
3990
3991
3991
- 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.**
3993
3993
3994
3994
##### Example: HTML Minification and Compression
3995
3995
@@ -4425,13 +4425,14 @@ registerServiceWorker();
4425
4425
4426
4426
[^118]CodeSandbox: Implementing Offline Capabilities with Service Workers.
4427
4427
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.
4429
4429
4430
4430
- The code above demonstrates how to register a Service Worker for offline capabilities.
4431
4431
- First, it checks if the browser supports Service Workers.
4432
4432
- 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.
4433
4433
- The Service Worker script can intercept network requests, cache assets, and manage offline behavior.
4434
4434
- 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.**
4435
4436
4436
4437
##### Example: Caching Assets for Offline Use
4437
4438
@@ -4472,12 +4473,13 @@ h1 {
4472
4473
4473
4474
[^119]CodeSandbox: Caching Assets for Offline Use.
4474
4475
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.
4476
4477
4477
4478
- The code above demonstrates how to cache assets for offline use using a Service Worker.
4478
4479
- During the Service Worker installation phase (`install` event), it opens a cache named `v1`.
4479
4480
- It then adds specified URLs (including HTML, CSS, JavaScript, and image files) to the cache using the `addAll()` method, embedded in `addResourcesToCache()`.
4480
4481
- 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.**
4481
4483
4482
4484
##### Example: Offline Data Synchronization
4483
4485
@@ -4512,12 +4514,13 @@ function syncData() {
4512
4514
4513
4515
[^120]CodeSandbox: Offline Data Synchronization.
4514
4516
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.
4516
4518
4517
4519
- The code above demonstrates how to perform offline data synchronization using a background sync event (`sync` event).
4518
4520
- The `syncMessagesLater()` asynchronous function registers a background sync from a browsing context.
4519
4521
- When a sync event with the tag `sync-data` is triggered, it calls the `syncData()` function.
4520
4522
- 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.**
# 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.
0 commit comments