HW Image Widget example

This is an example of the responsive, user friendly HW Image Widget available for WordPress 3.5 and up. Its free for download from WordPress.org.

Did you know it sports the TinyMCE WYSIWYG editor for the text?

WEB ARTISAN

Development by Håkan Wennerberg
YUI Compressor with NetBeans

YUI Compressor in NetBeans

Combining and compressing JavaScript in any web project is a necessity in most cases. Let me show you how you could use YUI Compressor to combine and compress JavaScripts files automatically for you when using NetBeans with a PHP project.

The key to this solution is in the “Project Properties” run configuration settings. Its typical to have it set to “Local Web Site” or similar so the start page shows up in your browser when pressing F6 (Run). You can still have this, and have some automation connected to it as well.

Download YUI Compressor

First of all we need to download the YUI Compressor JAR-file from Github. Then put it in your project root directory (for simplicity in this tutorial).

Configure NetBeans

Open up the project properties dialog and change the “Run As” combo box to “Script (run in command line)”. Uncheck the “Use Default PHP Interpreter” checkbox so that we can change the “PHP Interpreter” textbox. In the textbox you enter /bin/sh (I am using Linux in this case). Set the “Index File” to run.sh. The result will look like below:

NetBeans run configuration for YUI Compressor

Now we have a shell file that executes when the project is run, that means we can pretty much do anything before opening up the web page.

Automation script

Lets create the run.sh file in our project root folder:

nano run.sh

In it we will put actions that we would like to be performed on Run:

java -jar yuicompressor-2.4.8.jar \
    --type js \
    --nomunge \
    -o output.min.js \
    input1.js \
    input2.js

google-chrome http://mypage.com/

First we run the YUI Compressor with options of our liking. Then we use Google Chrome to open up the project in a web browser. This way we can still have it open in a web browser when the previous task finishes.

And there you have it, automated YUI Compressor in NetBeans!

Written by Håkan Wennerberg

Håkan (also known as PuffyThePirateBoy) is a systems architect based in Lundsbrunn, Sweden. Currently focusing on web development, Håkan is passionate about all aspects of web engineering ranging from back-end system infrastructure to front-end UX.

Outside of work, Håkan has a (slight) obsession about motorcycles and constantly trying to figure out how to get money for a bike, and what model it should be :)

Comments

Feel free to leave a comment using the form below.

Leave a Comment

Your email address will not be published. Required fields are marked *