myjs logo

myjs

A JavaScript interpreter for Python -- run .js against a DOM, call native C via ffi, reach the Python ecosystem

free macOS Programming Research Lab

myjs is a programming research lab tool. It's best for Python developers needing JavaScript execution and Developers requiring headless browser automation without a full browser. Pricing is free.

Pricing

free

Audience

Python developers needing JavaScript execution

Platforms

Community

0%

About myjs

myjs is a JavaScript interpreter for Python that allows running JavaScript files, rendering HTML pages headlessly, scripting the DOM, calling native C through FFI, and accessing the Python ecosystem from JavaScript without Node.js or a browser.

myjs provides a comprehensive JavaScript environment within Python, enabling developers to execute JavaScript code, interact with a full DOM implementation, and integrate with native C libraries. It supports standard web APIs like `fetch`, `WebSocket`, and ES modules, allowing for complex web application logic to be run directly from Python scripts. The interpreter handles asynchronous operations with Promises, `async/await`, `setTimeout`, and `setInterval`, ensuring a complete JavaScript runtime experience.

The tool offers robust headless HTML rendering capabilities, similar to Puppeteer but without the need for a separate browser download. Users can load URLs or local HTML files, apply CSS, execute JavaScript against the rendered page, fill forms, submit them, and wait for specific elements to appear. This makes it suitable for web scraping, automation, and server-side rendering (SSR) of web pages.

Beyond web-centric features, myjs extends JavaScript's reach into the system and Python ecosystem. It includes Node.js-flavored `fs`, `path`, `sh`, `http`, `os`, and `process` modules for file system operations, shell command execution, and HTTP serving. Crucially, it provides a Foreign Function Interface (FFI) to call any C library via `ctypes` and a `py` object to evaluate Python code, import Python modules (like `pandas` or `numpy`), and execute Python scripts directly from JavaScript. This bridges the gap between JavaScript, C, and Python, offering a powerful multi-language scripting environment.

Key Features

JavaScript interpreter for Python
Headless HTML rendering and DOM scripting
Full DOM implementation with ~190 constructors
Asynchronous operations with Promises, async/await, setTimeout
ES module import/export support
Thread-backed `fetch` for concurrent requests
RFC 6455 WebSocket client
Node-flavored `fs`, `path`, `sh`, `http` modules
Node-flavored `os` and `process` modules
Foreign Function Interface (FFI) to call C libraries via ctypes
Access to Python ecosystem from JavaScript (`py` object)
Console with format specifiers, table, group, count, time, assert
Native dialogs (prompt, confirm, chooseFile, chooseFolder) on macOS
Clipboard read/write access
Command-line interface for running files, evaluating snippets, rendering HTML
REPL with history, TAB completion, and top-level await

Pricing

free

myjs is available for free via pip install from PyPI.

Who is it for?

Best for

  • Python projects requiring embedded JavaScript execution
  • Headless web scraping and automation tasks
  • Server-side rendering of HTML pages with JavaScript
  • Projects needing to call native C libraries from JavaScript within a Python environment
  • Developers looking to leverage the Python ecosystem from JavaScript

Not ideal for

  • Users seeking a full-fledged browser environment for complex UI testing
  • Projects that strictly require Node.js-specific module ecosystems
  • Beginners unfamiliar with both Python and JavaScript development

Integrations

numpy pandas sqlite3 ctypes

Community Discussion

Sign in to contribute

No discussions yet. Be the first to share your experience!

Frequently asked questions