|Version 2 (modified by sderle, 7 years ago)|
When developing with OpenLayers, typically users will use the lib/OpenLayers.js file, which will append script tags to the DOM for each OpenLayers class. This method works fine for development, but due to network latency, is slow. Additionally, the content of these files is not compressed, so network transfer time is slower than it might be otherwise.
Creating a Single File
In addition, the OpenLayers build scripts strip unneccesary comments and whitespace to save space, using the jsmin library.
OpenLayers ships with two configurations to create a single file version:
- library: This file includes all of the OpenLayers code, other than code which is still in development at the time of a release.
- lite: This file includes a small subset of OpenLayers code, designed to be integrated into another application. It includes only the Layer types neccesary to create tiled or untiled WMS, and does not include any Controls. This is the result of what was at the time called "Webmap.js" at the FOSS4G Web Mapping BOF.
Creating your own Profile
Profiles are simple to create. You can start by copying library.cfg or lite.cfg to something else, e.g. myversion.cfg in the build directory, and then build it with the following command:
$ ./build.sh myversion
The beginning of the file should include pieces which need to be included before anything else. In the case of the default OpenLayers build, this is:
OpenLayers/SingleFile.js OpenLayers.js OpenLayers/BaseTypes.js OpenLayers/Util.js
If you wish to create a build where you must specify each file you wish to include, you should then add files to an '[include]' stanza, as lite.cfg does. If you wish to create a build where all files in the lib/ directory are included by default, and you wish to *exclude* certain files, you can do this by putting filenames under the [exclude] header. Look at the files library.cfg and lite.cfg in the build/ directory for examples of this behavior.
[include] OpenLayers/Control.js OpenLayers/Control/MouseDefaults.js OpenLayers/Control/PanZoom.js