Minifying Openlayers.js

Events happening in the community are now at Drupal community events on www.drupal.org.
barwonhack's picture

Has anyone managed to get the openlayers.js down to less than, say, 300k for use with the openlayers module?

Using the min.conf option with python build script pumps out a respectable 120k .js file ... but it doesn't work at all with Drupal Openlayers.

The library.conf option outputs a .js file "weighing" about 800k. This works with Drupal Openlayers module, but it is hardly worth the effort, saving only about 120kb.

Keen to hear form others re any other experiences in optimising openlayers.js

:) S.

Comments

openlayers_slim is a

tmcw's picture

openlayers_slim is a middle-ground approach, but basically you'll need to edit the .cfg files to add things you need and remove things you don't - there's probably not a version that's perfect for your needs, but it's very easy to mix & match components. The OpenLayers module's behaviors will notify you whether the behavior is available in your library before you activate it.

Great - but Cloudmade and Google support

barwonhack's picture

Thanks - a pretty a pretty good outcome file size wise.

Not rendering Cloudmade or Google Maps and I am struggling to see how to enable that.
Should I create a new Projection within Openlayers (where to do that?) or ...?

Google support you'll need to

tmcw's picture

Google support you'll need to add, by adding the layer type (something like Layers/Google.js) in the .cfg, and rebuild. Cloudmade you need to download & point your install to the .js in the OpenLayers UI.

Thank a lot @tmcw the slim

ckreutz's picture

Thank a lot @tmcw the slim version worked nice for me for Cloudmade. I only added popup.js, because I needed these and excluded some controls. There used to be a nice page to customize the openlayer script, but I cannot find it anymore. You could select all different options and it generated your customized version. Anyway yours works fine for me.

You're probably thinking of

tmcw's picture

You're probably thinking of OpenLayerer, which lets you customize OpenLayers piece-by-piece. It's a little buggy because of the underlying OpenLayers code and I haven't had much time to maintain it, but you can give it a shot.

Great that was what I meant.

ckreutz's picture

Great that was what I meant. Really like it as I need different kind of scripts and it is a nice overview.

Location and Mapping

Group organizers

Group categories

Wiki type

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: