Achilles
Achilles

Reputation: 11309

Multiple References to the JQuery Library in a page

I have an ASP.NET application using a master page. I am adding a reference to the JQuery library in the master page however there are some content pages and user controls that reference the JQuery library directly. Will I need to remove each reference from those pages or can I leave them in place even though I am adding a reference into the master page of the application?

Upvotes: 2

Views: 730

Answers (3)

Armstrongest
Armstrongest

Reputation: 15429

If you're loading jQuery with the Script Manager, it should load only once.

If you still want intellisense, you can use the following trick:

<% if (false) { %>
  <script src="....... script tag here
<% } %>

Upvotes: 1

Roger Walsh
Roger Walsh

Reputation: 339

You will need to remove them I'm afraid. Came across this issue myself and the javascript will break.

Upvotes: 0

Nick Craver
Nick Craver

Reputation: 630569

You should remove them, including the library twice has many side-effects, wiping out any plugins defined for example. It'll load fine, but you'll start getting .pluginMethod is not defined, etc.

To avoid the headaches, only include them once, or register the script with the same key, and let ASP.Net do the include, and with the same key, it'll do so only once.

Upvotes: 1

Related Questions