Wednesday, May 28, 2014

Visual Studio and Javascript Intellisense

I don't know why I didn't track this down earlier, but as I was coding some jQuery AJAX today, I thought to myself, why isn't there Intellisense for jQuery? I mean, MS supports a whole plethora of other items, including Python, so why not js? Well it seems I just didn't do a quick Google search to find out about the ~/Scripts/_references.js file.

_references.js

It's really simple, you just add references to your js files in this folder of the format:

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

And voila, I have intellisense.  And if you're really lazy you can simply 
  • right-click this file --> 
    • "Auto-sync Javascript references"
    • "Update Javaascript references"
And anytime you add or remove a file, this reference is updated.

Sources:
http://madskristensen.net/post/the-story-behind-_referencesjs
http://www.asp.net/visual-studio/overview/2012/visual-studio-2012-javascript-editor

No comments:

Post a Comment