Manual:Live preview

Live preview is a feature of MediaWiki which allows showing a preview of an article or section on an edit form without reloading the remaining HTML code of the form.

It has some bugs, see live preview tracking bug for an up to date list.

Advantages

 * less incoming traffic: wikicode and all the menus are not received from the server again,
 * faster response time,
 * same cursor position in the editing window.

Disadvantages
Only preview area is updated, which means:
 * optional css files might be missing (e.g. if user adds &lt;source> tag),
 * scripts are not executed if they do not use the  hook.

Technical details
A live preview of an arbitrary MediaWiki markup string is returned if an appropriate flag is set when submitting a page via the "edit" action.

The following arguments to index.php should be passed via POST request:
 * 1) title=Page_Title
 * 2) wpPreview=true
 * 3) live=true
 * 4) wpTextbox1=String

The result is a preview of the string passed as the value of the wpTextbox1 field. This is similar to the result of  index.php parameter when viewing a page.

The title argument is actually used only if the string contains magic words such as.

Implementation
This feature should be exploited by JavaScript code with a "Live preview" button on the edit form. This button should submit the text with  flag and show resulting preview.

Live preview is currently disabled on Wikimedia projects, probably due to potential incompatibilities with some older browsers.

However, several userscripts are available, like qPreview and Quick Preview.

Also a script using built-in preview.js is possible.

Other uses
Live preview can be potentially used in a way other than in the edit form. For example, the current timestamp on the English Wikipedia is the 14-digit number within the result of the executing the following command:

Alternatives
A similar preview functionality is now implemented in API, using the parse function. As an example, the current time stamp can be obtained by:

Enabling live preview
Live preview is on or off depending on the $wgLivePreview variable of LocalSettings.php (MW ≤ 1.16.5). To activate it you must also enable it on a per-user basis in the "editing" tab of you user preferences page.