Question

I have 2 references to jQuery in my master page which is currently configured for production release:

<script type="text/javascript"
 src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js">
</script>
<%--<script type="text/javascript" src="../Scripts/jquery-vsdoc.js"></script>--%>

When I'm developing, I uncomment the vsdoc version so that I get intellisense in VS2008 and then switch it back before deploying it - except for the times that I forget. Is there a way to have intellisense in dev and use the Google CDN in prod that doesn't require an edit to deploy? i.e. a conditional inclusion dependent on environment...

EDIT: If I specify this file: http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js as my JavaScript file then VS2008 (with patch) will look for this file: http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min-vsdoc.js (with -vsdoc just before the .js) to use for intellisense. The problem is that Google does not provide the second named file in that location.

Another acceptable answer would be the answer to this question: "How do I get Google to put a jquery.min-vsdoc.js file at http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/ ?"

Was it helpful?

Solution

The suggested workaround (since Google doesn't host the documentation) is to reference the documentation script in a way that will never be included, for example

<% if (false) { %>
    <script type="text/javascript" src="../Scripts/jquery-vsdoc.js"></script>
<% } %>

OR

<asp:PlaceHolder runat="server" Visible="False">
    <script type="text/javascript" src="../Scripts/jquery-vsdoc.js"></script>
</asp:PlaceHolder>

OTHER TIPS

Visual Studio should automatically look for the vsdoc one for the intellisense.

If your script that is on the page is named "jquery.min.js" then visual studio will look for "jquery.min-vsdoc.js" in the same location.

you'll need to have this hotfix though:

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

Here is a blog post by Scoot Gu on the JQuery intellisense.
Just wanted to point to this blog because it is more exhaustive and worth a read.

Apart from that I think John Boker has answered the question.

If you're looking for a VS2008-compatible solution, I use the following:

<%= "<script type='text/jscript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script>" %>
<% /* %><script type="text/javascript" src="../../App_Data/jquery-1.3.2.js"></script><% */ %>

Blogged about it here: jQuery hosted on Google's CDN with IntelliSense

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top