Including 'domapi' in your pages
DomAPI exists as a series of small .js files. By keeping the library in many small units, we gain the following:
- Reduced bandwidth
Since the .js files are separate, the user's browser will cache them after the first download. Subsequent visits to your page (or other pages that use DomAPI) will result in faster performance, since the browser doesn't need to go back to the server and download them again.
- Increased modularity
By segregating code functions into smaller files, we make code maintenance easier. We also decrease download times, as we don't need to include the entire API, just the portions we will use.
DomAPI contains sophisticated methods for loading and managing the individual code units, but in order to use them, you need to manually load the domapi unit. We do this using a SCRIPT tag. Example:
Your actual path may vary.
The "../" part in the path means "go up one directory", while the slashes "/" mean "go into this directory".
Depending on where you installed DomAPI, you may have to move up a number of directories to get at the domapi.js file.
Most of the first-time-use errors you may encounter have to do with you not referencing the correct directory. If your browser starts spewing "Object Not Found" errors, or some similar "helpful" message, always double check those "../"''s in your path!
Testing if the Library is Loaded.
You can test whether you've correctly loaded the library byt searching for the existence of the 'domapi' object. For example:
You set most DomAPI settings after the domapi.js file has loaded, however there are a few settings that must be set as the library is loading. These settings include what theme to use, whether or not to perform skinning and whether or not the theme should be applied to the document body. You can change these settings directly in your SCRIPT include. Use of them is entirely optional. As an example, suppose I wanted my page to be fully skinned in the 'aqua' theme, including the page body. I would accomplish this by altering by script include as follows:
The possible environment variables are: