We’re at the point of trying to optimize LANDBOSS, and one of our first tasks was to combine our multitude of javascript files into a single one. Many browsers do not handle a large amount of requests on a page load gracefully, and it can become a major bottleneck. The problem we ran into was:
- Javascript code can be difficult to maintain simply due to what the language encourages, developing in a single file would make a large application almost impossible to work with
- Using multiple javascript files causes many HTTP requests on page load
- Tools to combine multiple javascript files into a single one were all lacking
On the 3rd item I suppose I should explain what I mean by “lacking.” I tried out a couple tools already available to combine/build a single javascript file, but each tool exhibited one or more of the following:
- Required a list of every single file to combine (meaning if you added a file you had to remember to update your list)
- Was not able to place certain dependancy files before the files that used them
- Was generally buggy and unreliable
So, to remedy this the LANDBOSS team and I decided to make our own. And so the “InterWorks JS Build” program was wrought in the dimmly lit cubicle-forge of Runak’Dur. It’s a terribly named, but rather useful program. It’s a command-line (read: automatable) .NET executable that uses a simple XML project file to include/exclude specific files or entire directories in the order you specify. It also uses the YUI Compressor for .NET to minify the results. All the guts are in a separate dll in case you want to put a spiffy GUI on top of it or something. We’ve integrated this application into 2 of our projects already with smashing success, and encourage you to try it on your own projects. You can find a download link below, and the readme file documents how to make the XML file and run the program. Enjoy!