Pyr.js: Python and R in HTML pages, with one script tag
Thierry Moudiki released pyr.js, a roughly 460-line single-file JavaScript library that runs Python and R code embedded in HTML pages entirely in the browser, built with Anthropic's Claude writing the code and tests from his design decisions. The library relies on Pyodide (Python compiled to WebAssembly) and webR for R, and connects code to the DOM through attributes such as py-click, py-out, r-click and r-input, with py-then and r-then passing results as data to JavaScript chart libraries including Observable Plot, Highcharts and D3. Moudiki reports that the first visit downloads several megabytes of engines and Python startup takes about 3 seconds, while hosting pyr.js on the same site lets Python run in a shared worker that other tabs and page reloads reuse.
pyr.js: Python and R in HTML pages, with one script tag , and kindly contributed to T. Moudiki's Webpage - R https://thierrymoudiki.github.io//blog/2026/11/15/python/r/javascript/pyr js R-bloggers https://www.r-bloggers.com/ . You can report issue about the content on this page here https://www.r-bloggers.com/contact-us/ Want to share your content on R-bloggers? click here https://www.r-bloggers.com/add-your-blog/ if you have a blog, or here http://r-posts.com/ if you don't. What if you could put Python or R code in an HTML page, double-click the file, and have it run? No server, no build step, no install, and nothing sent anywhere: everything runs in the browser. That’s what pyr.js https://github.com/Techtonique/pyr.js does. I built it this week with Claude Anthropic’s AI assistant , which wrote the code and tests from my design decisions and verified everything in a headless browser. The heavy lifting is done by Pyodide https://pyodide.org/ Python compiled to WebAssembly and webR https://docs.r-wasm.org/webr/latest/ same thing for R . pyr.js is the glue: a single file, about 460 lines you can actually read, that finds the Python and R code in your page and connects it to your HTML. A first example Save this as an .html file and open it in your browser: