Extension:Minify

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
Minify

Release status: experimental

Implementation User interface
Description Compresses CSS and JS from action=raw
Author(s) Robert Rohde (Dragons_flightTalk)
Last version 0.8.0
License BSD
Download Download snapshot
Subversion [Help]

Browse source code
View code changes

Hooks used
RawPageViewBeforeOutput

Check usage (experimental)

Contents

[edit] What can this extension do?

Minify bundles the YUI CSS compressor by Julien Lecomte and Isaac Schlueter with the JSMin Javascript compressor by Douglass Crockford and Ryan Grove.

When installed it automatically catches calls to RawPage.php and pre-compresses the CSS and Javascript output generated there. This can significantly reduce the size of CSS and Javascript files that are dynamically returned by Mediawiki, such as Mediawiki:Common.css and Mediawiki:Common.js. However, it does not affect the static files living in /skins/, etc.

The resulting files are functionally identical but have been stripped of user friendly formatting, comments, and similar elements.

Tests with files in use at the English Wikipedia suggest that in some cases the use of this extension can reduce CSS and Javascript file size by up to 50% (this is measured after gzip compression is also applied, i.e. the normal method of compression for data transmitted over the internet). Typically the largest share of the gains comes simply from removing comments.

[edit] Requirements

  • Mediawiki >= 1.10
  • PHP >= 5.0

[edit] Download instructions

You can download this extension via the MediaWiki extension distribution system, or via Wikimedia SVN.

[edit] Installation

This extension has a one-line installation and no configurable options. After copying the downloaded files to /extensions/Minify, simply add the following to LocalSettings.php:

require_once("$IP/extensions/Minify/Minify.php");

[edit] Known bugs

In rare cases (generally involving poorly formed javascript), JSMin may produce code that is not functionally identical. See [1] for a discussion of circumstance where this may occur. A test sample of javascript from the English Wikipedia did not reveal any cases where this was an issue.

Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox