Friday, 6 March 2009

If you want an online js and css minifyer go here and use ScriptMixer. The guys have wrapped the YUICompressor lib.

The offline version can also combine files whilst minifying and obfuscating js and css files too.

So to use in netbeans builds do this:-
1) Download the offline version from here,
2) Put it in your ant lib directory, windows default for nb 6.5 is 
     C:\Program Files\NetBeans 6.5\java2\ant\lib
3) For js combining, choose an include file name say compressed.js and use this as the include in your html/jsp files.


4) add something like the following to your project build.xml substituting the filename for your own:-

Job done, this has saved the overhead of 3 JS files by combining into one, making them smaller and obfuscating them, all automaticly in the build process.

Works a treat.




Saturday, 8 November 2008

Updated - Minified Javascript and CSS files in netbeans

If you want automated minified javascript and css files in your netbeans generated war files during the build process do the following :-
These two files need to go in your netbeans ant\lib folder, for my windows/netbeans 6.5 installation thats C:\Program Files\NetBeans 6.5\java2\ant\lib.

For web applications that you want to build with compressed js/css files add the folloing xml to the build.xml for the project, overiding the "-pre-dist" ant target which is not currently configured by default in netbeans.

<target name="-pre-dist" >
<condition property="dont.do.compression">
<istrue value="${auxiliary.org-netbeans-modules-web-client-tools-api.clientdebug}"/>
</condition>
<antcall target="-do-compression"/>
</target>
<target name="-do-compression" unless="dont.do.compression" >
<echo level="info" message="Compressing JavaScript and CSS files...." />
<path id="yuicompressor.classpath">
<fileset dir="${ant.home}/lib">
<include name="yuicompressor-2.3.5.jar"/>
</fileset>
</path>
<taskdef name="yuicompress" classname="com.yahoo.platform.yui.compressor.YUICompressTask" >
<classpath>
<path refid="yuicompressor.classpath"/>
</classpath>
</taskdef>
<yuicompress linebreak="16000" warn="false" munge="no" preserveallsemicolons="true"
outputfolder="${basedir}/${build.web.dir}" >
<fileset dir="${basedir}/web" excludes="**/ext-2.2/**/*.js" >
<include name="**/*.js" />
<include name="**/*.css" />
</fileset>
</yuicompress>
<echo level="info" message="Compression Complete" />
</target>

On the line that includes <include name="yuicompressor-x.x.x.jar"/>
replace the x's with the version of the library you are using.

Then set your includes and excludes as per the example above.

This works for netbeans versions 6.1 onwards including 6.5.

Compression only takes place if client side debugging is configured off.


Sunday, 26 October 2008

Is NetBeans 6.5 Release Candidate Ready for FCS?

Well, been using netbeans 6.5 beta and dev builds on and off for a while now and found a few niggles and stability issues with some of them. Nothing serious though which have mostly been addressed.

Downloaded 6.5 RC1 and WOW what an improvement in stability ! 

I am using this release all the time now for my main development which is usually database driven web applications.

The new features I like best are :-

  •  Speed up improvements
It is very much quicker in terms of start up and does not seem to suffer the pregnant pauses when bringing up hover overs like previous releases.
  •  Stability
It has not crashed, locked up or phoned home yet!
  •  Database Explorer changes
Having the ability to page through and update data from the IDE is great. I tend to use PL/SQl so coupled with the PL/SQL plugin it is getting close to not needing another database tool. Not quite there yet, I feel there is a need for the ability to at least list the database objects you have rights on even in other schema's.
  • Client Side Javascript Debugger
Especially IE support which I am stuck with at work, although I tend to use Google Chrome for speed unless I need to debug. 

So is NetBeans 6.5 RC ready for FCS
I would say definitely YES from a web app development point of view.

Neils Netbeans Wish List
  •  Google Chrome Javascript debugger plug in if possible.
  •  Cross Schema listing of all database objects you have rights on in the database explorer.
  •  Automatic minified Javascript/CSS builds.
  •  Geronimo Application Server Plug in.
My favourite general IDE feature is the ability to undock windows to another monitor in a multi monitor setup, especialy where you have a desktop with the ability to show and switch between multiple desktops.

Wednesday, 13 August 2008

Minified Javascript and CSS files in netbeans

If you want automated minified javascript and css files in your netbeans generated war files during the build process, read on...

Since netbeans now has a Javascript debugger we want to suppress JavaScript and CSS file compression, it confuses the hell out of the js debugger as you might expect. So I have modified the build.xml from my earlier example to ignore compression when client side debugging is switched on.

So to get automated minified javascript and css files into your war files during the netbeans build process do the following :-
These two files need to go in your netbeans ant\lib folder, for my windows/netbeans 6.5 RC1 installation thats C:\Program Files\NetBeans 6.5 RC1\java2\ant\lib.

For web applications that you want to build with compressed js/css files add the folloing xml to the build.xml for the project, overiding the "-pre-dist" ant target which is not currently configured by default in netbeans.

<target name="-pre-dist" >
<condition property="dont.do.compression">
<istrue value="${debug.client}"/>
</condition>
<antcall target="-do-compression"/>
</target>
<target name="-do-compression" unless="dont.do.compression" >
<echo level="info" message="Compressing JavaScript and CSS files...." />
<path id="yuicompressor.classpath">
<fileset dir="${ant.home}/lib">
<include name="yuicompressor-x.x.x.jar"/>
</fileset>
</path>
<taskdef name="yuicompress" classname="com.yahoo.platform.yui.compressor.YUICompressTask" >
<classpath>
<path refid="yuicompressor.classpath"/>
</classpath>
</taskdef>
<yuicompress linebreak="16000" warn="false" munge="no" preserveallsemicolons="true"
outputfolder="${basedir}/${build.web.dir}" >
<fileset dir="${basedir}/web" excludes="/ext-2.1/**/*.js" >
<include name="**/*.js" />
<include name="**/*.css" />
</fileset>
</yuicompress>
<echo level="info" message="Compression Complete" />
</target>


On the line that includes <include name="yuicompressor-x.x.x.jar"/>
replace the x's with the version of the library you are using.

This works for netbeans versions 6.0,6.1,6.5 beta and 6.5 RC1. In 6.1 compression only takes place with debugging configured off, in 6.5 files are not compressed when run in debug mode, which is now a seperate option to 'run' on the toolbar.

enjoy...

Wednesday, 23 July 2008

Instant Messenger Plugin for Netbeans ?

Anyone know of an IM plugin for netbeans ?

Sunday, 22 June 2008

Compressing Javascript files in netbeans 6.1 - A solution

OK, I have a working solution for netbeans 6.1, I can not take any credit for this as my hunch was correct, it has been done before. I have adapted the work done by Philippe Mouawad and ANDREW GOMILKO using the YUI Compression tool as Ant Task so that it can be used with netBeans 6.1 web application projects.

To get automated javascript \and css files into your war files during the netbeans build process do the following :-

These two files need to go in your netbeans ant\lib folder, for my windows/netbeans 6.1 installation thats C:\Program Files\NetBeans 6.1\java2\ant\lib.

For web applications that you want to build with compressed js/css files add the folloing xml to the build.xml for the project, overiding the "-pre-dist" ant target which is not currently configured by default in netbeans.

<target name="-pre-dist">
<echo level="info" message="Compressing JavaScript and CSS files...." />
<path id="yuicompressor.classpath">
<fileset dir="${ant.home}/lib">
<include name="yuicompressor-2.3.5.jar"/>
</fileset>
</path>
<taskdef name="yuicompress"
classname="com.yahoo.platform.yui.compressor.YUICompressTask">
<classpath>
<path refid="yuicompressor.classpath"/>
</classpath>
</taskdef>
<yuicompress linebreak="300" warn="false" munge="no"
preserveallsemicolons="true"
outputfolder="${basedir}/${build.web.dir}" >
<fileset dir="${basedir}/web"
excludes="/ext-2.1/**/*.js" >
<include name="**/*.js" />
<include name="**/*.css" />
</fileset>
</yuicompress>
<echo level="info" message="Compression Complete" />
</target>
This will compress and copy the js and css files to the build directory before the war file is built and will thus be included in your war file.

Note there is a line in my example with an "exclude" for my ext-2.1 directory, the files there are already compressed so i have excluded them, just add/remove to suit your application.

The payload without compression on my current project is 880kb after compression 620kb, and has shaved a couple of seconds off the browser load time too.

All we need now is for someone to code a netbeans plugin that configures this all for us and makes it configurable from a wizard maybe, any takers ?

I have also stumbled upon this excellent nb6.1 plug-in for pl/sql editing be sure to check it out if you want to edit pl/sql from within netbeans.

Happy coding....

Saturday, 21 June 2008

Compressing Javascript files in netbeans 6.1

After reading the ant manual and contemplating this further I couldnt help thinking that someone might have already built an ant task to do this.

A quick google search yielded several interesting results:-

  • http://blog.tremend.ro/2006/10/25/ant-task-for-javascript-compression/
  • http://code.google.com/p/jsmin-ant-task/
  • http://javaflight.blogspot.com/2008/01/introducing-yui-compressor-ant-task.html

According to YUI Compressor pages, it is JavaScript minifier designed to be 100% safe and yield a higher compression ratio than most other tools including JSMin.

I am going to have a go at modifying an ant task to use the YUI Compressor and add it to a test web app build script in netbeans.

There are step by step instructions on how to create the ant script on slideshare here.