· via dev.to (home feed)
PyScript runs real Python in the browser via WebAssembly, no build step
PyScript embeds real CPython or MicroPython in HTML pages via WebAssembly, with two-way DOM access, PyPI packages and Web Worker support, and no build tools or backend required.

Python embedded directly in HTML
According to a dev.to article, PyScript is an open-source platform developed by Anaconda and first unveiled by the company's CEO Peter Wang at PyCon US 2022. It lets developers embed Python code in HTML pages using standard script tags, and that code executes natively in the browser. The setup demonstrated in the article consists of a stylesheet and a JavaScript module pulled from pyscript.net, with the example built on the 2025.11.1 release. After that, a script tag of type "py" runs Python on the page. There is no build step, no npm install and no bundler: two tags in the document head are enough to start writing Python.
Two interpreters compiled to WebAssembly
The dev.to piece stresses that PyScript is not a transpiler or a syntax trick: it is real Python executing through WebAssembly, with two interpreters available, both compiled to WASM.
The first, Pyodide, is the original CPython interpreter ported to run entirely inside the browser sandbox. Per the article, that brings the full Python standard library, most pure-Python packages from PyPI, and pre-compiled WASM binaries for scientific computing stacks including NumPy, Pandas, Matplotlib and Scikit-learn. The article demonstrates this by plotting a sine curve with Matplotlib directly inside a page.
The second, MicroPython, is a lightweight reimplementation of Python 3. Its WASM build weighs around 170KB, which the article describes as dramatically smaller than Pyodide, making it a fit for mobile and tablet browsers, pages where startup time matters, and simpler apps that do not need the full CPython standard library. Both interpreters implement the same foreign function interface, so switching between them is mostly a matter of changing the script tag's type attribute.
A two-way bridge between Python and the page
The FFI is presented as the centerpiece of the platform: a bi-directional bridge in which Python can call JavaScript and JavaScript can call Python. Python code reaches the DOM through a document object, with the article showing a click handler registered via addEventListener, or through a higher-level Pythonic API in pyscript.web along with a "when" decorator that binds events to CSS selectors. Browser APIs are exposed through a window object covering items such as alert, console logging and localStorage.
The bridge also works in the other direction. JavaScript can execute Python code through pyscript.interpreter.run, illustrated in the article by evaluating the string "2 + 2" and logging the result of 4.
Workers, packages and ready-made components
By default, Python runs on the browser's main thread, so CPU-heavy work, with the article citing data crunching, image processing and ML inference, would freeze the interface. Adding a worker attribute to the script tag moves execution into a Web Worker, each with its own Python interpreter, and results stream back to the page through PyScript's messaging API.
Packages install through a JSON configuration attribute or a dedicated py-config tag listing PyPI names such as pandas and requests, while MicroPython uses its own package manager, mip. PyScript also ships two interactive components: an embedded terminal that renders a live REPL on the page, and a CodeMirror-based editor with a run button, both aimed at documentation, tutorials and educational tools without a backend. The platform itself sits on a lean core called PolyScript, with most functionality layered on through a community plugin system that keeps the core small.
Why it matters
Since the web's beginnings, JavaScript has been the only language browsers executed natively; Python could only prepare pages on a server. PyScript, running on WebAssembly, removes that constraint. The Python ecosystem, including the scientific stack, can now execute client-side on data that never leaves the user's machine, and interactive teaching tools can work without any backend at all. The remaining friction is payload and startup cost, which is exactly why MicroPython ships alongside Pyodide. For frontend development, the long-standing requirement that a tab must speak JavaScript is beginning to loosen.
- #python
- #webassembly
- #pyscript
- #browsers
- #frontend