Reputation: 10297
I read in "jQuery for ASP.NET Developers" this re: getting Intellisense support in VS for jQuery: "....a VSDoc file for jQuery...The VSDoc file...uses the same name as your JavaScript file with -vsdoc inserted before the .js file extension. For example, if my jQuery file is called jQuery-1.3.2.js, then the vsdoc file would be called jQuery-1.3.2-vsdocjs. the VSDoc file must exist in the same directory as your jQuery file so that VS can find it."
Does this mean that using a CDN for jQuery files prevents Intellisense from working?
Upvotes: 4
Views: 3246
Reputation: 408
You can use a CDN and still have Intellisense support in Visual Studio. There are two ways to do this:
Add an Intellisense reference to the *vsdoc.js
file that is hosted
on the CDN. Go to Tools | Options
:
Note that you will need to make an entry for each *vsdoc.js
that
you want to use.
*vsdoc.js
file is co-located in the same directory with the js
file on the CDN (like it is on the ASP.NET CDN), AND you're using MVC, you can just update your _references.js
file to reflect this:/// <reference path="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.0.js" />
If you need help with _references.js, see my blog entry here.
Be sure to update your webpage (or _Layout.cshtml) reference to actually use the CDN too. Note that the js
path that you use for your web pages doesn't have to be the same as your Intellisense reference (of course, you obviously want them to be the same version)!
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
</head>
<body>
<div id="body">
@RenderBody()
</div>
<script src="@Url.Content("http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.js")" type="text/javascript"></script>
@RenderSection("scripts")
</body>
</html>
NOTE: The examples above assume that you're not using ASP.NET 4.5 bundling, or taking advantage of CDN features such as path mirroring and reverse proxies. I assume that if you're using these features, you know what needs to be done to get them running.
Upvotes: 5