Instant Diffs (ID) is a free open-source JavaScript tool that enhances MediaWiki diff and revision links with interactive previews. Instead of navigating to a separate page, users can view, compare, and interact with diffs directly in context, loaded on demand in the overlay dialog via AJAX.
The gadget works across all standard MediaWiki interface pages where diffs and revision links appear, including local and global watchlists, local and global user contributions, new pages, recent changes and logs, as well as in user-generated content such as talk pages and project pages.
Install Node.js and package dependencies:
npm install
Make a copy of the environment variables file, configure your project, and fill in all necessary fields:
Unix:
cp env.json.example env.json
Windows (PowerShell):
Copy-Item env.json.example env.json
The env.json file contains configuration objects for different deployment environments. Each configuration object (e.g., testwiki, mediawiki) supports the following parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
dir |
string |
required | Directory containing the built files (e.g. dist) |
name |
string |
required | Base name of the script (e.g. instantDiffs) |
server |
string |
required | MediaWiki server URL (e.g., https://www.mediawiki.org) |
scriptPath |
string |
required | MediaWiki script path (e.g., /w) |
target |
string |
required | Target page on the wiki where the script will be deployed. Use the $name placeholder for the script name (e.g., MediaWiki:Gadget-$name) |
i18n |
string |
required | Target path for internationalization files. Use the $name placeholder for the script name (e.g., MediaWiki:Gadget-$name-i18n/) |
i18nDeploy |
boolean |
true |
Whether to deploy external language files. Automatically set to false in development mode (--dev flag) |
i18nBundle |
string[] |
["en"] |
Array of language codes to bundle with the main script. English (en) is always included even if not specified |
legalDeploy |
boolean |
true |
Whether to deploy legal notice files |
rateLimit |
number |
0 |
API rate limit in requests per minute. Set to 0 for no rate limiting |
retries |
number |
0 |
Number of retry attempts for each failed individual request |
credentials |
object |
{} |
Authentication credentials for siddharthvp/mwn library (Interface MwnOptions). Typically includes username, password, and userAgent |
esbuild |
object |
{} |
Optional build configuration for esbuild. Passed to the esbuild.build() function (e.g., { "target": "es2016" }) |
To start a local development server (uses the local project configuration from env.json):
npm run start:local
Or specify a custom project configuration name:
cross-env PROJECT=local npm run start
To deploy to a wiki, specify the project configuration name (e.g., mediawiki):
cross-env PROJECT=mediawiki npm run deploy
If you deploy the script as a gadget, remember to define the gadget in your wiki's MediaWiki:Gadgets-definition page with a configuration like this:
* instantDiffs [ResourceLoader | dependencies=site, mediawiki.api, mediawiki.util, mediawiki.storage, mediawiki.notification, mediawiki.Title, oojs] | instantDiffs.js | instantDiffs.css
If you want to preload a language other than English, link the language file to the end of the definition, for example:
instantDiffs.js | instantDiffs.css | instantDiffs-i18n/uk.js