I want the following call to render only if such call wasn't already declared in a parent view.
@Scripts.Render("~/Scripts/jQuery")
What's the best way to do so?
I want the following call to render only if such call wasn't already declared in a parent view.
@Scripts.Render("~/Scripts/jQuery")
What's the best way to do so?
Here is one way:
<script>
if (!window.jQuery) {
document.write('<script src="@BundleTable.Bundles.ResolveBundleUrl("~/Scripts/jQuery")">\x3C/script>');
}
</script>
This is essentially the same logic used when one includes jQuery from a CDN, and then has a local reference fallback if the CDN delivery failed.