Skip to content

Commit 30914ef

Browse files
committed
rephrase examples of what works with web workers and what doesn't
1 parent cf3fe61 commit 30914ef

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

docs/user-guide/plugins.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,28 @@ this adds great flexibility it's important to understand that workers actually h
8383
comparing to code executed on the main thread. For instace, while PyScript offers a DOM API that actually can
8484
be used in web workers on the browser, by default, does not allow DOM operation in workers. So, in this case,
8585
if you just use `window` and `document` directly mapping the Javascript FFI provided directly by the interpreters
86-
we support (Pyodide and MicroPython): `from pyscript import window, document` will work and allow you to interact
87-
with the DOM while `from js import window, document` will not.
86+
we support (Pyodide and MicroPython). With that in mind, `from pyscript import window, document` will work and
87+
allow you to interact with the DOM while the following will not:
88+
89+
```
90+
from js import document, window
91+
```
92+
93+
or
94+
95+
```
96+
import js
97+
js.document
98+
```
99+
100+
or
101+
102+
```
103+
import js
104+
js.window
105+
```
106+
107+
will not.
88108

89109
In general, we recommend executing your code on workers unless there are explicit reasons preventing users from
90110
doing that.

0 commit comments

Comments
 (0)