Generated by GPT-5-mini| GJS (GNOME JavaScript bindings) | |
|---|---|
| Name | GJS |
| Developer | GNOME Project |
| Released | 2006 |
| Programming language | C (programming language), JavaScript |
| Operating system | Linux |
| Genre | Application programming interface |
| License | GNU Lesser General Public License |
GJS (GNOME JavaScript bindings) is a set of language bindings that enable the use of JavaScript to create applications and components for the GNOME Project platform. It integrates the SpiderMonkey JavaScript engine with GNOME libraries such as GObject-based frameworks, allowing developers to script desktops, extend GNOME Shell, and build standalone applications. GJS is used by core projects and third-party applications that target the GTK ecosystem across Linux distributions.
GJS provides bindings between Mozilla's SpiderMonkey and GNOME technologies like GObject, GLib, GTK+, GIO, and GObject Introspection. It exposes GNOME API surface areas familiar to contributors to GNOME Shell, GNOME Software, Files and other desktop components, enabling integration with systems such as systemd, NetworkManager, PulseAudio, PipeWire, and D-Bus. The project is maintained by contributors from organizations including Red Hat, Canonical, SUSE, and independent volunteers active in the GNOME Foundation community.
GJS originated in the mid-2000s as part of efforts to bring scripting to GNOME components originally scripted with languages like Python and Vala. Early work drew on Mozilla technologies such as SpiderMonkey and coordination with projects like Mozilla Corporation and XULRunner. Major milestones include adoption in GNOME Shell during the GNOME 3 development cycle, collaboration with distributions such as Fedora and Debian for packaging, and modernization efforts to support newer ECMAScript standards adopted by TC39 proposals. Contributions have come from developers affiliated with companies like Canonical, Red Hat, and community contributors participating in events like GUADEC.
The architecture pairs a C-language wrapper around SpiderMonkey with automatic introspection via GObject Introspection metadata. Core elements include a binding layer that maps GObject classes and methods to JavaScript prototypes, a garbage collection bridge between JS and GLib's memory model, and modules to expose libraries such as GTK, Clutter, Pango, Cairo (graphics), GStreamer and GIO. Features include support for ES6 constructs such as promises and classes through modern SpiderMonkey updates, compatibility with GTK 3 and GTK 4, and tooling for integration with GNOME Shell extensions and application development workflows used by distributions like Arch Linux and openSUSE.
GJS leverages GObject Introspection to generate bindings that present GNOME APIs as idiomatic JavaScript objects. The API surface enables access to modules including GLib, GObject, Gio, Gtk, Gdk, Cairo (graphics), Atk and GtkSourceView. Event-driven patterns align with GNOME conventions such as signals and main loops provided by GLib Main Loop, while promise-based async patterns interoperate with GNOME asynchronous APIs like GIO's asynchronous I/O. The binding design promotes interoperability with language ecosystems represented by projects such as PyGObject, Vala, Rust GNOME bindings, and C (programming language) libraries.
GJS is the scripting substrate for GNOME Shell extensions, powering user-visible customization and features shipped in distributions like Ubuntu, Fedora, and Manjaro. Core GNOME components such as GNOME Shell Extensions, GNOME Software, and certain utilities integrate GJS-based modules. Third-party applications and projects including Geary, Fractal, and desktop widgets have used GJS to speed development and leverage GNOME platform services like D-Bus APIs, NetworkManager, and AccountsService. Integration with desktop accessibility stacks such as Assistive Technology Service Provider Interface via Atk ensures compatibility with assistive technologies supported by organizations like the Free Software Foundation Europe.
Performance of GJS depends on SpiderMonkey optimizations, garbage collection tuning, and the overhead of crossing the language boundary to C (programming language) libraries. Projects often profile with tools like perf (Linux tool), Valgrind, and sysprof to diagnose hotspots. Security considerations include sandboxing and privilege separation patterns when running untrusted extensions, adherence to AppArmor or SELinux policies on distributions, and limiting access to sensitive APIs such as D-Bus system interfaces and file-system operations. Upstream and distribution maintainers collaborate with projects such as Canonical and Red Hat to address vulnerabilities and coordinate timely updates aligned with CVE disclosure processes.