Summary: Embed (static) JavaScript into wiki pages
Version: 2006-07-17
Status: Stable
Maintainer: Pm
Discussion: JavaScript-Talk?

Questions answered by this recipe

  • How can I embed static JavaScript into a wiki page?

(For information about using wiki markup to create or edit JavaScript, see JavaScript-Editable.)

This section is optional; use it to indicate the types of questions (if any) this recipe is intended to answer.


Getting JavaScript into a wiki page is easily done by creating a custom markup for it. For example, provides me with the following JavaScript code for displaying weather information on a webpage:

<script src=''></script>

So, to create a custom (:weather:) markup that will output this JavaScript code, define a custom markup in local/config.php or a group customization as:

Markup('weather', 'directives',
  Keep("<script src=';par=null&amp;unit=0&amp;key=77351fbfbbfc1099f80fa310e5f58b52'></script>"));

This results in:

Injecting JavaScript

You can inject JavaScript either in the skin template, or in the $HTMLHeaderFmt or $HTMLFooterFmt arrays.

Examples using the arrays:

  • see scripts/stdconfig.php injecting pub/pmwiki-utils.js.
  • $HTMLHeaderFmt['specific- javascript'] =
       // the JavaScript code to be injected

See Also


  • Pm


See discussion at JavaScript-Talk?

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.