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.

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. This feature can be exploited by userspace JavaScript code by:


 * 1) adding a "Live preview" button to the edit form;
 * 2) submitting with that flag and showing the resulting preview, without changing the rest of the HTML page.

As a result, when the user clicks the "Live preview" button, the preview of the current text is shown without reloading the entire page. A userspace JavaScript exploiting live preview this way is en:User:Pilaf/Live Preview.

Technically, a live preview of a string is returned by passing the following arguments to index.php:


 * 1) title=Page_Title
 * 2) wpPreview=true
 * 3) live=true
 * 4) wpTextbox1=String

These arguments have to be passed via a POST request. The result is a preview of the string passed as the value of the wpTextbox1 field. The title argument is actually used only if the string contains templates such as.

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

curl -f -m 60 -d "" "http://en.wikipedia.org/w/index.php?title=Main_Page&action=edit&wpPreview=true&live=true&wpTextbox1="

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