If you’re using multiple javascript files, you want YUI Loader (and may not already know it)

The advantages of using a baked library are obvious. Sometimes, when you have to manage the dependencies, it can quickly become a nightmare. Thankfully, with .NET, the IDE generally takes care of making sure you have your references set. This is not so with javascript. The order in which they appear on the page matters. When you are using technologies like Master Pages, things can get even more hairy. Enter YUI Loader. YUI is a javascript library from your good friends at Microsoft (whoops… that sale hasn’t go through... yet)… I mean Yahoo. There are a tonne (metric AND imperial) of controls and each comes with its own set of dependencies contained within the library. Adding 2 or 3 controls to your pages can quickly get your <script type="text/javascript"> references to be quite a lengthy as well as unruly list.

Thankfully, Yahoo provides a tool they call YUI Loader that has the smarts baked into it regarding what dependent javascript files are needed. You simply provide it with a name and it loads it up. If you have multiple, simply put them all into the list and, voila, it also makes sure the dependencies are also loaded up properly for those as well. I highly recommend using this tool, if you’re using other or multiple javascript libraries and even if you’re not using YUI for anything else… yeahp it handles javascript other than just the YUI stuff too.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s