Minifying scripts

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Minifying scripts

appleton
What is the recommended method of minifying scripts that use OpenLayers?

I have tried Google's Closure Compiler in advanced mode but it renames the OpenLayers functions that are being called, like OpenLayers.d.Zoom

Is there a way to tell Closure to NOT minify any of the OpenLayers calls?

Or is there a better minifier for OpenLayers scripts?

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Minifying scripts

Xavier Mamano (jorix)
Hi,

The code of Openlayers 2.x does not support "ADVANCED_OPTIMIZATIONS" of Closure Compiler. Use "SIMPLE_OPTIMIZATIONS".

Try use "build.py -c closure your-configuration.cfg" from "build" folder  (see http://www.openlayers.org/dev/build/README.txt and http://docs.openlayers.org/library/deploying.html)


Code  not

appleton wrote
What is the recommended method of minifying scripts that use OpenLayers?

I have tried Google's Closure Compiler in advanced mode but it renames the OpenLayers functions that are being called, like OpenLayers.d.Zoom

Is there a way to tell Closure to NOT minify any of the OpenLayers calls?

Or is there a better minifier for OpenLayers scripts?

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Minifying scripts

robertdbuckley
In reply to this post by appleton
hi,

I have good experience with this http://fmarcia.info/jsmin/test.html

Yours,

Robert


Von: Richard Jones <[hidden email]>
An: [hidden email]
Gesendet: 15:58 Sonntag, 4.November 2012
Betreff: [OpenLayers-Users] Minifying scripts

What is the recommended method of minifying scripts that use OpenLayers?

I have tried Google's Closure Compiler in advanced mode but it renames the OpenLayers functions that are being called, like OpenLayers.d.Zoom

Is there a way to tell Closure to NOT minify any of the OpenLayers calls?

Or is there a better minifier for OpenLayers scripts?

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users



_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Yours with thanks, Robert Buckley System: Linux Ubuntu 10.04 Server / Tomcat6 / Geoserver 2.1.2 / GeoWebCache 1.2.6)
Reply | Threaded
Open this post in threaded view
|

Re: Minifying scripts

eriktronic
In reply to this post by appleton
appleton wrote
I have tried Google's Closure Compiler in advanced mode but it renames the OpenLayers functions that are being called, like OpenLayers.d.Zoom

Is there a way to tell Closure to NOT minify any of the OpenLayers calls?
I am using OpenLayers with Closure in advanced mode. In order to do this you need to make an externs file (or multiple) containing all the functions you wish to use. You can even add types to the parameters to force yourself to use the functions correctly. See https://developers.google.com/closure/compiler/docs/api-tutorial3#externs for a nice example.

Regards,
Erik
Reply | Threaded
Open this post in threaded view
|

Re: Minifying scripts

erilem
On Mon, Nov 5, 2012 at 10:15 PM, eriktronic <[hidden email]> wrote:
> appleton wrote
>> I have tried Google's Closure Compiler in advanced mode but it renames the
>> OpenLayers functions that are being called, like OpenLayers.d.Zoom
>>
>> Is there a way to tell Closure to NOT minify any of the OpenLayers calls?
>
> I am using OpenLayers with Closure in advanced mode.

Which doesn't mean you're compiling the OpenLayers code with the
Closure compiler.

> In order to do this you
> need to make an externs file (or multiple) containing all the functions you
> wish to use.

It sounds like you compile your application using the Closure compiler
and use OpenLayers as an external, non-compiled lib.


--
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 94
Mail : [hidden email]
http://www.camptocamp.com
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Minifying scripts

eriktronic
Indeed I am compiling my own code that uses the external OpenLayers library.
But as I understood this is what appleton was looking for.
Reply | Threaded
Open this post in threaded view
|

Re: Minifying scripts

erilem


On Monday, November 5, 2012, eriktronic wrote:
Indeed I am compiling my own code that uses the external OpenLayers library.
But as I understood this is what appleton was looking for.

Indeed.

Out of curiosity, are you using just the Closure compiler, or both the Closure compiler and the Closure library?


--
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 94
Mail : [hidden email]
http://www.camptocamp.com

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Minifying scripts

eriktronic
erilem wrote
Out of curiosity, are you using just the Closure compiler, or both the
Closure compiler and the Closure library?
I use both the compiler and the library.
And I actually hope OpenLayers will work with advanced mode itself in the future, that would be perfect.
Reply | Threaded
Open this post in threaded view
|

Re: Minifying scripts

erilem


On Monday, November 5, 2012, eriktronic wrote:
erilem wrote
> Out of curiosity, are you using just the Closure compiler, or both the
> Closure compiler and the Closure library?

I use both the compiler and the library.
And I actually hope OpenLayers will work with advanced mode itself in the
future, that would be perfect.


OL2 won't. OL3 will, presumably. Have you started looking at OL3? (Sorry for high-jacking this thread a bit.)


--
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 94
Mail : [hidden email]
http://www.camptocamp.com

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Minifying scripts

eriktronic
I just read about OL3 5 seconds ago haha. So I don"t know if there is any pre-release or ETA for v3?
Will dive into that tomorrow, first get some sleep. Good night.
Reply | Threaded
Open this post in threaded view
|

Re: Minifying scripts

appleton
In reply to this post by appleton
Thanks for the tips.

I'm actually accessing the openlayers library directly from my script like this:

<script src="http://www.openlayers.org/api/OpenLayers.js"></script>

I assume that is allowed?

So I'm just needing to minify my own script.

The advanced mode of Closure seems to change other things like "document" so I gave up on it and used the simple mode instead. I've also written a quick SED script to shorten global variables before feeding to closure - together that seems to do all the minifying I need at present.

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Minifying scripts

Xavier Mamano (jorix)
Hi,

The key to reducing more the code is to compress only the necessary components (using simple mode of Closure by build.py). This is what has been done in OpenLayers.mobile.js 375Kb and OpenLayers.light.js 280Kb (OpenLayers.js 722Kb)

Download the zip of 2.12 and see the folder /duild/, you will find "mobile.cfg" and "light.cfg", edit one to create "your-configuration.cfg" file and use it with "python build.py -c closure your-configuration.cfg ../OpenLayers-custom.js", and then use "OpenLayers-custom.js". That's all.

See https://github.com/openlayers/openlayers/blob/master/build/README.txt !!

NOTE: "api" is the last stable release, so 2.12.

appleton wrote
Thanks for the tips.

I'm actually accessing the openlayers library directly from my script like this:

<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
I assume that is allowed?

So I'm just needing to minify my own script.

The advanced mode of Closure seems to change other things like "document" so I gave up on it and used the simple mode instead. I've also written a quick SED script to shorten global variables before feeding to closure - together that seems to do all the minifying I need at present.

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users