[HOME] jsMath (Users) [Up]

jsMath Global Mode

One of jsMath's weaknesses is its speed (or lack thereof). Since jsMath has to interpret each mathematical expression and then typeset it, this can be a time-consuming process. To help improve the performace, jsMath includes an equation cache where it stores the typeset versions of the expressions that you are viewing, and it uses that cache if the same expression shows up again. This is helpful to a degree, but only when exactly the same expression occurs more than once on the page. (There is also a sub-expression cache that helps when several formulas include common terms.)

Because of the way that JavaScript works, the equation cache is cleared whenever you go to a new page, so the typesetting that occurred on one page does not carry over to the cache on the next page you view. (In general, each page is its own "environment" and one page cannot interact with another, for security reasons.) This means that much of the benefit of having a cache is lost when you move from page to page.

To help overcome this problem, jsMath has a "Global Mode". This uses a "frame set" that contains a main page where the equation cache can be stored, and an inner frame in which the jsMath document is shown. When you link to a new page from that document, only the contents of the inner frame are refreshed, and the outer frame is left unchanged. Since jsMath stores its cache in the outer frame, that means the cache will remain intact even as you move from page to page. Thus the performance of jsMath should improve as you view more pages.

To initiate Global Mode, open the jsMath Control panel (using the "jsMath" button usually found at the lower right-hand corner of the page) and press the "Go Global" button. (Some pages may initiate Global Mode automatically, so if you see a "Go Local" button, you are already in Global Mode.) The page should reload, and you probably will not see any visial difference, except that the "jsMath" button will now say "jsMathGlobal" instead. In Global Mode, the equation cache will be preserved as you move from page to page.

It is important to realize that Global Mode uses an HTML frame set, even though it appears that you are just viewing a single page. The use of framesets introduces the usual complications that accompany pages that use frames. In particular, printing and refreshing the page becomes more delicate, and the address bar and window title show the location and title of the outer frame not the page in the inner frame. If you reload the main page while in Global Mode, this will reinitialize the frameset, and the global equation cache will be lost. Worse yet, in some browsers, you will go back to the page you were on when you first started using Global Mode. Depending on the browser you use, printing the main page may not produce the results you expect: some browsers will print only the portion of the inner frame that actually appears on screen, rather than the whole document, and may include the scrollbars and other window decorations.

JsMath tries to alleviate the problems in several ways. First, the jsMath Control Panel includes "Print" and "Reload" buttons that will let you easily print or reload the contents of the inner frame. Some browsers provide contextual menu items that allow you to print or reload individual frames, but not all do, so jsMath provides that alternative for you. Second, jsMath will set the window title to the title of the inner document (when it can), so that the effect is the same as though there were no frames involved.

The main difficulty is that jsMath can't set the address area to show the location of the inner page (since that would cause a new page to open in place of the frameset). Instead, jsMath's Global Mode provides an optional Global Control Bar where the actual page location can be displayed (and changed). This bar is not shown by default, but you can activate it by clicking on the word "Global" in the "jsMathGlobal" button, or by clicking the "Controls" button on main jsMath Control Panel. Either of these should open a small panel at the top of the page that includes an address area and several action buttons.

The address area shows the address of the document being shown in the inner frame, so you can more easily tell what page is being displayed. You can also edit this address and press RETURN (or the "Go" button) to view a new page instead. Note, however, that this address bar does not include address auto-completion, even if the browser's main address bar does.

The other buttons include:

While jsMath tries hard to address the problems of using a frame set, the solution is not without its shortcomings. One major limitation is that in order for the outer frame to communicate with the document in the inner frame, both must come from the same server (this is part of the JavaScript security model). If you navigate to a page that is not from the same server, the page will be displayed, but jsMath will not be able to look up the title or the address, and so will not be able to show these in the Global Control Bar. Furthermore, the "Print" and "Reload" buttons will not be available for those pages, so you will have to rely on your browser's contextual menu items for that.

It is possible for links inside the inner frame to cause their linked page to open as the main page, rather than staying within the inner frame. This would cause the global frame to be lost, and so jsMath would effectively go back to local mode. Depending on the settings in the jsMath Options panel, the next page that uses jsMath could cause Global Mode to start up again automatically, but that might not be the case. Since jsMath does not control the contents of the pages to which you link, there is little that it can do to prevent this.

If you view a jsMath page in Global Mode and then navigate to other offsite locations, jsMath's global frame will continue to be present (the idea is that you might navigate offsite temporarily, and then go back to pages with jsMath that could still take advantage of the global equation cache, so the frame is not removed until you explicitly request it). Even though you can't see the jsMath outer frame, it may still be there, and unless the jsMath button is visible, it may be hard to tell. One indication is that the address bar shows the jsMath-global.html file and will not change as you travel to new pages. If you wish to leave Global Mode when the jsMath Control Panel or Global Control Bar are not available, the only way to do this is to type a new address into the address bar to replace the jsMath global file. That will take you to the new page and remove the jsMath global frame.

Finally, you should be aware that going to global mode will cause the current page to be reloaded. If the page was generated as a result of submitting a form, this could cause the form to be submitted a second time. Most browsers will warn you about that, and ask whether it is OK to resubmit the data, but not every browser does so. Also note that hiding or showing the Global Control Bar can cause the page to be reloaded in some browsers.


Get jsMath at SourceForge.net. Fast, secure and Free Open Source software downloads [HOME] jsMath web pages
Created: 02 May 2006
Last modified: 10 Apr 2007 18:04:10
Comments to: dpvc@union.edu
[Up] jsMath Home Page