Developing with jQuery in Microsoft Visual Studio 2008 - Page 5

As it turns out, making this work in Visual Studio really didn't require modifying Visual Studio at all. In my case, I started with a Visual Studio installation that knew nothing about jQuery. To get Visual Studio to understand jQuery, all I did was add a single line of code to my source file:

<script src="jQuery-1.2.6-vsdoc.js" type="text/javascript"></script>

This source file is actually identical to the standard jQuery JavaScript file (the first of the two I was talking about earlier), except all the functions and objects in it have been annotated with special comments. These comments tell IntelliSense about the objects as it parses the file. This feature has been with Visual Studio 2008 since it was released in November 2007. What's new here is that somebody took the time to annotate the jQuery file. That's it; no enhancements to Visual Studio were necessary.

Programmers can run their code with this annotated version of jQuery if they like; they don't have to use the unannotated version. However, most people prefer to release tighter code. To do so, they can replace the line with one that loads the regular jQuery JavaScript file. If they're creating an ASPX page, they can use the fancy version I showed earlier with the C# code present.


The support for jQuery isn't technically an enhancement to Visual Studio so much as a special version of jQuery that Visual Studio's IntelliSense recognizes. However, it does the job, and it does it well. Somebody spent a lot of time putting it together, and this should really help people who write jQuery code in Visual Studio.

But this might also get you thinking, as it did me. Certainly you can annotate all your JavaScript files so that IntelliSense is fully aware of them. Here's one page I found online that shows you how to do just that, from Scott Guthrie's ubiquitous blog. (Guthrie also explains how IntelliSense handles JavaScript differently from other languages, going into more detail than I did earlier.)

And if you're ambitious, you can take any other JavaScript library, open source or otherwise, and go though and annotate it. In fact, some people already have. If you have a favorite library, search Google and you might find the annotated files out there.

Jeff Cogswell is a senior editor at Ziff Davis Enterprise and writes the MSDev blog for DevSource, found at He can be reached at [email protected]