Tales from the Evil Empire

Bertrand Le Roy's blog

News


Bertrand Le Roy

BoudinFatal's Gamercard

Tales from the Evil Empire - Blogged

Blogs I read

My other stuff

Archives

Visual Studio patched for better jQuery IntelliSense

Jeff King just announced the release of a patch for Visual Studio 2008 that enables the IDE to find the –vsdoc.js file without requiring the developer to reference it.

To give some context, a documentation file (basically the same file as the runtime script but with XML documentation annotations) can be provided to help Visual Studio provide IntelliSense. Until now, you had to reference that extra file explicitly, usually within a server-side <% if %> block so that the file never gets included at runtime.

Now that this patch shipped, this is no longer necessary and Visual Studio is going to be able to find the –vsdoc.js file for any script file that is referenced, whether that is through a ScriptManager ScriptReference:

jQueryIntelliSenseScriptReference

or using a plain script tag:
jQueryIntelliSenseScriptTag

or even a reference XML tag:
jQueryIntelliSenseReferenceTag

That makes jQuery IntelliSense as easy as dropping the –vsdoc.js file in the web site next to the main jQuery file (other libraries can easily take advantage of that too of course):
jQueryIntelliSenseFileLocation

Pretty sweet.

The patch can be found here:
http://code.msdn.microsoft.com/KB958502/Release/ProjectReleases.aspx?ReleaseId=1736

The IntelliSense file for jQuery can be downloaded from the jQuery servers (look for the “documentation: Visual Studio” file):
http://docs.jquery.com/Downloading_jQuery#Download_jQuery

Jeff’s post:
http://blogs.msdn.com/webdevtools/archive/2008/11/07/hotfix-to-enable-vsdoc-js-intellisense-doc-files-is-now-available.aspx

Jeff’s other post on using the documentation file:
http://blogs.msdn.com/webdevtools/archive/2008/10/28/rich-intellisense-for-jquery.aspx

The format for XML doc comments:
http://weblogs.asp.net/bleroy/archive/2007/04/23/the-format-for-javascript-doc-comments.aspx

Comments

labilbe said:

Thank you Bertrand for sharing!

# November 8, 2008 2:48 AM

Peter said:

As I commented on Jeff's blog, a resource manager feature where I could tell the IDE what JS/CSS files it should assume are going to be available at runtime, would be a better option in my opinion. The IDE can't possible cover all the possible combinations of how a JS file would end up in the final HTML. So why not just cut out the guess work and let us tell it. It would be easier for the users to understand -- if it's not defined in the "resource manager" then you need to do define it there -- rather than trying to understand why the IDE couldn't figure out that my JS/CSS file would be available at runtime. No?!

# November 8, 2008 2:47 PM

Steve said:

This did not work for me

# November 8, 2008 7:02 PM

Steve said:

Does this require me to use the uncompressed version of jquery ?

I'm using asp.net mvc.

I installed the updated

I downloaded, and put the file in my scripts directory next to my jquery-1.2.6.min.js file

I goto my .js file and I get no intellisense for jQuery

# November 8, 2008 7:07 PM

Bertrand Le Roy said:

@Steve: if you're using the min file, you need to rename the vsdoc file too, to jquery-1.2.6.min-vsdoc.js.

# November 10, 2008 12:38 AM

Lev said:

This is pretty cool but it doesn't work in User controls.  Most of our application logic is in user controls, not pages or external js files.  Are there any plans to make this work in user controls?

# November 14, 2008 3:08 PM

Angus McDonald said:

Very nice. I agree with Peter though.

It would be helpful for me if it worked with VS2008 Team System as well (this patch doesn't).

# November 19, 2008 5:37 PM

Angus McDonald said:

Urgggh ... scratch that comment about VSTS, I actually needed to get onto SP1 first!

# November 19, 2008 7:22 PM

Shyju said:

Is it not available for Visual studio 2005 ?

# May 11, 2009 2:37 AM

Bertrand Le Roy said:

@Shyju: no.

# May 11, 2009 12:46 PM

KiT said:

Thanks. It works great.

However, it works on .aspx and .htm(l) files but not .js file.

Is there any way to make it work on .js file?

# November 10, 2009 1:59 PM

Bertrand Le Roy said:

@KiT: you mean even after you added the reference tag?

# November 10, 2009 2:12 PM

KiT said:

Do I need to add a reference tag in the .js file? How?

Sorry for asking such a naive question.

I am still new to this area.

What I have done is I put the -vsdoc.js in the same folder as jquery library file and add a reference to the jquery library under the <head> section of an html file.

It seems like the -vsdoc.js is loaded automatically since I can see from its intellisense.

However, when I tried to see the intellisense in an external javascript (.js) file, it doesn't appear as expected.

Thanks :)

# November 11, 2009 7:34 AM

Bertrand Le Roy said:

@KiT: yes, there is an example of that in the post. You just add a comment like this:

/// <reference path="jquery-1.2.6.js"/>

No need to reference the vsdoc file directly, VS will find it from the path you provide.

# November 11, 2009 3:12 PM

KiT said:

@Bertrand: Wow! Thanks a bunch. That does the magic. However, it takes time for the intellisense to show the expected functions. (I'm using Resharper - doubting if it could be the cause of the delay.)

# November 12, 2009 10:37 AM

Bertrand Le Roy said:

@KiT: yes, the speed is not optimal in 2008 (although still very usable imo). In VS 2010, you don't even feel it, it's immediate. And much better as well, it does amazing things.

# November 12, 2009 2:04 PM

Ulf E said:

I do have huge problem in 2010, not getting intellisense to work ok at all.

Often not getting intellisense at all.

Hope things get better

# November 27, 2009 4:58 PM

Bertrand Le Roy said:

@Ulr E: try deleting your VS settings and restarting.

# November 27, 2009 8:58 PM

microgen said:

# December 30, 2009 3:14 AM

shafaqat309 said:

Hi

I did the same steps but still not working.

I have downloaded, patch for vs 2008, vsdoc.js file and also i have referenced it on aspx page but still no success.

# March 31, 2010 2:10 AM

Bertrand Le Roy said:

@shafaqat309: I'd contact Jeff King on his blog post (linked) or contact support.

# March 31, 2010 2:27 AM