I have an MVC 3 Razor partial page that is dependent on jquery.validate.js and jquery.validate.unobtrusive.js.
Is it possible for the partial page to check whether or not there is, already, a reference to the .js packs?
Since this is a partial page, it’s possible/probable that either the _Layout.cshtml or another included partial page has already referenced the .js packs. To avoid duplicate references to the .js packs, I would like the partial page(s) to be able to determine if it needs to add the reference to the packs or not.
You can check if
jQueryandjQuery.validateare defined and load the script if it’s not, but it’s not really worth the effort – browsers are caching js files, so if you have two references, it will only download it once.