Extending applications with JavaScript

As JavaScript is becoming more ubiquitous, we see more people teaching it, learning it, and more pieces of software starting to allow their users to customize or extend them via JavaScript plugins or extensions.

Some programs are well known for allowing customisation via JavaScript, like Atom or HyperTerm, mostly because they have a philosophy behind them aiming to maximize extensibility or because they’re written either in JavaScript or languages that compile to JavaScript in the first place.

We created a list of the most outstanding programs that can be extended with JavaScript, not considering in this list JavaScript frameworks or Node system scripts – we are planning to write some posts about them soon. The list, in no particular order, is the following:

Atom

Atom is a text editor well known for being extensible and lightweight, so much that it can be extended into a full-fledged IDE through existing or custom plugins.
The project is maintained by GitHub, and it’s meant to be extended from the get-go, it is basically just a bare editor with a good number of default plugins. Also all of its configuration can be written in code (though most of it can be done through the UI as well), and you get the benefit of disabling any default plugin you may consider unnecessary.

Atom comes with a flight manual to get you started using the editor, configuring it and writing plugins quickly and effectively. It also offers a first contact with the API, where you will find almost every part of the program exposed, from the core functionality and editor actions to theming and configuration. You can check the list of existing packages and install them from the configuration screen, or use apm command to install them from the command line.

JetBrains IDEs

WebStorm and IntelliJ are JetBrains IDEs that we use a lot, and though they can already be extended by writing Java extensions, Script Monkey plugin brings Java’s robustness and JavaScript’s flexibility together by exposing IntelliJ Open API and running your scripts in the Nashorn JS engine in the same JVM. Since it gives the developer access to virtually every aspect of the IDE, it aims to achieve nearly anything that can be done with Java. There are already lots of plugins that you can browse from the plugins configuration screen or via the official plugin repository.

HyperTerm

Hyperterm is a terminal emulator developed in HTML and JavaScript (using React and Redux) running on Electron and Node. It allows to extend every bit of functionality by composing existing components with your own higher order components. You can find the API documentation in the project’s home page, together with the configuration and existing actions references. You can use hpm to install existing plugins from the npm repository.

Photoshop

Probably one of the most known graphics editors, allows extensibility via plugins written in AppleScript, VBScript and JavaScript. There’s a General scripting guide that provides an introduction to scripting in all three languages, and there’s a more specific JavaScript reference.
The API exposes almost every object, action and piece of interface, from documents, layers, channels and selections, to preferences, measurement tools, workspaces, and history.
This allows the developer to create, remove, modify and manipulate almost any object, programmatically apply filters, work with the clipboard, load, resize, crop and save documents.

This alone provides possibilities for a wide range automation and customization, but we found two more tools that take it a step forward: Parametric Curves plugin, which allows to define adjustment curves using javascript functions instead of having to manually input it with the curve editor, and Adobe Configurator utility, meant to create custom panels using HTML and JavaScript that lets the developer add a graphic user interface to custom actions.

Google Chrome

One of the most popular web browsers, exposes an extensive API that allows extensions to manipulate most of its functionality and interfaces. There are tons of tutorials out there to get you started with creating extensions in no time.
Also worth mentioning, Tampermonkey is a Chrome extension (also available for other browsers) that injects any custom piece of JavaScript code you write to pages of your choosing, this allows you to customize the websites you visit in any way you need or want. Also the user scripts can be shared, so there are plenty of scripts out there already available for you to use.

Let us tell you why we think it’s worth it to allow this kind of extensions.

For a start, JavaScript extensions are usually easy to write, there’s no need for SDKs, compilers, runtime environments, or any additional software.
If you don’t know JavaScript, chances are you know a language with C-like syntax and will feel comfortable with it right away. And given the growth and push JS is having nowadays, it’s an excellent tool to have in your toolkit.
The source code is available to you by default (unless the developer decided to obfuscate it).
And it’s just as powerful as any other option. Even if the application you’re extending is not written in JS, you’ll likely have access to the same classes and API you would in the original language.

We hope to see this list growing with more applications. If you think a program can be added to the list, or have any feedback, please leave a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *