summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-12-08 14:54:02 -0800
committerBrion Vibber <brion@pobox.com>2010-12-08 14:54:02 -0800
commit26bd15ec0ac50eb80609e3a2c5574c8d7b2eaefa (patch)
tree747ebdc20c226d481344544b061f94acab3225ef /plugins
parentfb315c6f618d8b1635442c70964f7ab14e53385e (diff)
Mapstraction plugin: use minified sources for OpenLayers
The default full build of OpenLayers.js is 943kb as of 2.10; this gzips down to a couple hundred kb but is still rather nasty, plus loading it off a remote host could slow things down. Using a local copy let us cut down the size significantly by discarding unused features, and further minification with yui-compressor shaves a bit more off. Cuts down to about 1/5 the size of the original. Also threw in a bundled & minified copy of the Mapstraction classes plus our usermap.js, which covers the common case of using the default OpenLayers provider. This cuts out three additional script loads, two of which weren't getting launched until after the mxn.js main file got loaded.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Mapstraction/MapstractionPlugin.php22
1 files changed, 15 insertions, 7 deletions
diff --git a/plugins/Mapstraction/MapstractionPlugin.php b/plugins/Mapstraction/MapstractionPlugin.php
index d5261d8bc..e9e28d78d 100644
--- a/plugins/Mapstraction/MapstractionPlugin.php
+++ b/plugins/Mapstraction/MapstractionPlugin.php
@@ -128,8 +128,8 @@ class MapstractionPlugin extends Plugin
$action->script('http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6');
break;
case 'openlayers':
- // XXX: is this not nice...?
- $action->script('http://openlayers.org/api/OpenLayers.js');
+ // Use our included stripped & minified OpenLayers.
+ $action->script(common_path('plugins/Mapstraction/OpenLayers/OpenLayers.js'));
break;
case 'yahoo':
$action->script(sprintf('http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=%s',
@@ -140,11 +140,19 @@ class MapstractionPlugin extends Plugin
return true;
}
- $action->script(sprintf('%s?(%s)',
- common_path('plugins/Mapstraction/js/mxn.js'),
- $this->provider));
-
- $action->script(common_path('plugins/Mapstraction/usermap.js'));
+ if ($this->provider == 'openlayers') {
+ // We have an optimized path for our default case.
+ //
+ // Note that OpenLayers.js needs to be separate, or it won't
+ // be able to find its UI images and styles.
+ $action->script(common_path('plugins/Mapstraction/usermap-mxn-openlayers.min.js'));
+ } else {
+ $action->script(sprintf('%s?(%s)',
+ common_path('plugins/Mapstraction/js/mxn.js'),
+ $this->provider));
+
+ $action->script(common_path('plugins/Mapstraction/usermap.js'));
+ }
$action->inlineScript(sprintf('var _provider = "%s";', $this->provider));