Reputation: 3848
I saw this in code. It blew my mind.
<% if (false) { %>
<script type="text/javascript" src="~/Scripts/jquery-1.3.2.js"></script>
<% } %>
This seems so patently illogical that it must be intentional. I can only assume that somehow this "came up", and somebody inserted this as a work-around. There are, of course, no comments.
Why would someone do this?
Upvotes: 8
Views: 2785
Reputation: 35871
That's a trick to get Visual Studio to include the javascript Intellisense for jQuery without actually emitting the script to callers.
Here is an example from Scott Gu explaining it.
Upvotes: 12
Reputation: 24395
Intellisense in Visual Studio works for jQuery if you add that to every .aspx, .ascx file.
But instead of including it in every file it is included only in the masterpage.
Visual Studio parses the markup files and finds a reference to jQuery and then uses the provided intellisense on it.
You'll also need to add a vsdocs.js file into the project.
You can read more about it here.
Upvotes: 8
Reputation: 14233
To comment out code.
ASP does not respect HTML comments, so some people will use this, not knowing that ASP has its own syntax for comments.
Upvotes: 2
Reputation: 39966
is there another line of code that looks like
<script type="text/javascript" src="~/Scripts/jquery-min.1.3.2.js"></script>
or similar? My guess is whoever wrote this wanted to have an easy way to switch in the big jQuery file for debugging purposes
Upvotes: 2
Reputation: 39913
if(false) is a quick and dirty way to comment out a bunch of code
Upvotes: 4