Extension:HeaderScriptInjector

Summary
This extension creates $wgHeader global variable, pointing to the object of class 'HeaderScriptInjector'. You will be able to access functions of this extension through the $wgHeader variable.

To use HeaderScriptInjector in your extension, within your extension file add a line: global $wgHeader;

Libraries, local javascript files, css will be added through method calls: $wgHeader->loadLib(...);      //more details below $wgHeader->addScript($url);   //if your script depends on libraries add libraries before! $wgHeader->addCSS($url);

The goal of this extension is to add each item to the header only once, regardless of how many extensions use the same resource. Currently this is possible if all scripts/libraries/style sheets are added through the HeaderScriptInjector.

Add library from CDN
Attach a javascript library hosted by an external content distribution network (CDN) to your extension. i.e. you won't need to copy source of javascript to your server, page response might be faster due to possibly better robustness of the CDN

At the moment only Google Ajax API is supported.

$wgHeader->loadLib("jquery","google","1.2.6"); ^       ^        ^               library tag    CDN    version of the library

Check the list of libraries and their versions supported by Google AJAX libraries API.

Please make sure you are using correct library tag and version.

Installation
Create directory: extensions/HeaderScriptInjector Download extension file into that directory, add the following to your LocalSettings.php file: require_once("$IP/extensions/HeaderScriptInjector/HeaderScriptInjector.php");

If you are using Google AJAX library CDN you will need to add your Google API Key. Add a line in LocalSettings.php after "require_once". $wgGoogleApiKey = '....';