Skip to content

Commit 8106690

Browse files
Merge pull request #191 from pyscript/no-more-sabayon
Updated instructions around service-worker
2 parents a774f70 + 8196085 commit 8106690

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

docs/user-guide/workers.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,21 @@ Each `<script type="m/py">` or `<m/py-script>` may optionally have
7171
a `service-worker` attribute pointing to a locally served file (the
7272
same way `mini-coi.js` needs to be served).
7373

74-
* You can chose `mini-coi.js` itself or *any other custom service worker*,
75-
as long as it provides either the right headers to enable synchronous
76-
operations via Atomics, or it enables
77-
[sabayon polyfill events](https://github.com/WebReflection/sabayon?tab=readme-ov-file#service-worker).
78-
* Alternatively, you can copy and paste the
79-
[sabayon Service Worker](https://raw.githubusercontent.com/WebReflection/sabayon/main/dist/sw.js)
80-
into your local project and point at that in the attribute. This will
81-
not change the original behavior of your project, it will not interfere with
82-
all default or pre-defined headers your application uses already but it will
83-
**fallback to a (slower but working) synchronous operation** that allows
84-
both `window` and `document` access in your worker logic.
74+
Such file needs to orchestrate *coincident* *POST* requests so that:
75+
76+
* you can copy and paste the
77+
[coincident Service Worker](https://cdn.jsdelivr.net/npm/coincident/dist/sw.js)
78+
into your local project and point at that via the `service-worker` attribute.
79+
This will not change the original behavior of your project, it will not
80+
interfere with all default or pre-defined headers your application uses
81+
already but it will
82+
**fallback to a (slower but working) synchronous operation**
83+
that allows both `window` and `document` access in your worker logic.
84+
* you can import
85+
[coincident listeners](https://github.com/WebReflection/coincident/blob/main/src/sabayon/listeners.js)
86+
in your project and at least add the `fetc` one before your listeners.
87+
It will automatically stop propagation when a request is meant to be handled
88+
so that the rest of your logic will not be affected or change by any mean.
8589

8690
```html
8791
<html>
@@ -100,12 +104,12 @@ same way `mini-coi.js` needs to be served).
100104

101105
!!! warning
102106

103-
Using sabayon as the fallback for synchronous operations via Atomics
107+
Using *coincident* as the fallback for synchronous operations via Atomics
104108
should be **the last solution to consider**. It is inevitably
105109
slower than using native Atomics.
106110

107-
If you must use sabayon, always reduce the amount of synchronous
108-
operations by caching references from the *main* thread.
111+
If you must use `service-worker` attribute, always reduce the amount of
112+
synchronous operations by caching references from the *main* thread.
109113

110114
```python
111115
# ❌ THIS IS UNNECESSARILY SLOWER

0 commit comments

Comments
 (0)