Extension:Javascript

From MediaWiki.org

Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
Javascript

Release status: stable

Implementation User interface
Description Loads Javascript files from selected files or directories without duplication.
Author(s) User:Nad
Version 1.0.2 (2007-06-27)
MediaWiki all versions
Download Javascript.php

This extension allows you to manage multiple Javascript files imports from one place. The extension is a single script which you can obtain from OrganicDesign:Extension:Javascript.php and save into a directory called Javascript in your extensions directory and include in your LocalSettings.php file. Set the $wgJavascriptPaths to an array containing all the relative url locations of the directories and Javascript files you want added, this must be defined before the include line as in the following example,

$js = "/wiki/extensions/Javascript";  # Relative path from $wgServer
$wgJavascriptPaths = array(
    "$js/mootools.js",
    "$js/prototype.js",
    "$js/JavascriptToolbox"
    );
include("$IP/extensions/Javascript/Javascript.php");

In this example, the scripts are all located in the same directory as the extension script. The last javascriptToolbox item is a directory containing a number of related Javascript files which will all be imported.

Note that if this extension is included in your LocalSettings.php after all the other extensions, then those extensions may also add Javascript files to the $wgJavascriptPaths list to be imported.

[edit] Finding the correct paths and testing

Once you've saved your Javascript files in the locations you want them on your server, find the correct URL for them by typing the address into your browser, if it is correct you'll be able to load the Javascript file directly and see it in the browser. You can then use the part of the URL after the domain name as your correct relative path.

You can check which scripts have successfully been included by checking the Special:Version page, it shows links to the scripts it has loaded, following the link should take you to the Javascript file in the browser. If the script links are not showing up, then the extension could not find them at the path specified by $wgJavascriptPaths in your LocalSettings.php.

[edit] See also

Personal tools