Saturday, 19 September 2009

Checking Javascript Files With JSLINT in Netbeans

Enough about minifying JavaScript, what about checking JS files with JSLint too.

Try this in NetBeans:-

Download the latest lib from http://code.google.com/p/jslint4java/ and put in your ant/lib directory or on the class path. I put it in the netbeans project folder in the example.

Override the pre-compile ant target in your netbeans build.xml so that it looks something like the following example, substituting the class path and includes as appropriate:-



When you build your web application the chosen JavaScript files will be run through the JSLint ant task and checked for errors, the build will fail if any problems are found.

This has saved me hours of debugging JavaScript especially when using cross browser JS libs such as EXTJs.


Sunday, 19 July 2009

I have come across a brilliant idea for compressing and minifying CSS and Javascript.

Just check this out and forget my previous ramblings on the subject and enjoy :)


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 ?