[HOME] jsMath (Authors) [Prev][Up][Skip][Next]

The global plugin

As of version 3.3, jsMath includes an equation cache that it uses to try to speed up its processing of mathematical expressions. The HTML produced for each expression that jsMath processes is stored and if that same expression appears again, the HTML is obtained from the cache rather than generated again from scratch (there is also a sub-expression cache that can help when portions of equations appear more than once).

By default, the equation cache is cleared every time you go to a new page (this is a consequence of the fact that each new page gets its own JavaScript environment, and no data can be passed from one to the next). JsMath provides a mechanism for maintaining a global equation cache that is persistent across multiple pages. See the Global Mode documentation for more information on how this works.

The user can enter and leave Global Mode by means of the jsMath Control Panel, but it is also possible for the web page author to initiate global mode automatically when a page is viewed. You do this by including

    <SCRIPT SRC="path-to-jsMath/plugins/global.js"></SCRIPT>
just before the command that loads jsMath.js itself (and after setting any values for the jsMath variable, if any). Unless the user has explicitly requested not to go to Global Mode (by using the jsMath Control Panel on a previous page), this will cause the web page to load using the global equation cache. The user can leave Global Mode using the "Go Local" button on the jsMath Control Panel or the Global Control bar, as usual.

By default, the Global Control Bar will not be displayed when global mode is entered. You can change the default by setting

      jsMath = {Controls: {
         cookie: {global: "always", hiddenGlobal: 0}
before loading jsMath.js, but this time do not load global.js (jsMath will load the global cache itself). This will force jsMath into Global Mode, but with the Global Control Bar showing.

In addition to storing the equation cache, Global Mode can also be used effectively when files are taken from the local disk (rather than over the network from a web server). Since the web browser's cookie data are tied to specific servers, cookies are not usually allowed for local files. JsMath uses cookies to store the settings that can be changed via the jsMath Conrol Panel, and this does not work for local files. Instead, jsMath usually includes the cookie data as part of the URL for the file being viewed in these situations. This works if you only want to see a single file, but that data is lost if you link to another page, so the settings revert to their defaults again, which is inconvenient.

Since the data kept in the Global Mode is persistent across several files, this makes a natural storage area for the cookie data when local files are being viewed. JsMath will switch to this method rather than modifying the URL when Global Mode is used. This makes it more convenient to test jsMath files from a local disk, because the settings will act more like they do when actual cookies are used. For example, going back to a previous page will cause the mathematics to be rendered with the current settings, not the old ones from the last time you viewed that page (as would happen when the cookie data are included in the URL).

The noGlobal plugin

There may be situations where you do not want to allow the user to put jsMath into Global Mode (for example, if you are already using jsMath within a frame set, or in the case where reloading the page could be problematic). To do so, include the line
    <SCRIPT SRC="path-to-jsMath/plugins/noGlobal.js"></SCRIPT>
before loading jsMath.js. This will disable to Go Global button, and will prevent entering Global Mode. Note, however, that if the user has already entered Global Mode, this will not cause jsMath to go local.

Get jsMath at SourceForge.net. Fast, secure and Free Open Source software downloads [HOME] jsMath web pages
Created: 02 May 2006
Last modified: 13 Sep 2008 08:10:55
Comments to: dpvc@union.edu
[Next] The noCache plugin
[Skip] Browser Support for jsMath
[Up] Information for jsMath Authors
[Prev] Using jsMath without Image Fonts