I add a jquery path in bundle config.cs but give an below error
Create:52 Uncaught ReferenceError: $ is not defined
at Create:52
BundleConfig.cs
- public class BundleConfig
- public static void RegisterBundles(BundleCollection bundles)
- {
-
-
- bundles.Add(new ScriptBundle("~/Scripts").Include(
- "~/Scripts/jquery-3.4.1.min.js",
- "~/Scripts/jquery.validate.min"
- ));
when I create a new project in mvc
then Bydefault jquery add in project see below
Create.cshtml
- <h2>Create</h2>
- <div>
- <div>
- Name : @Html.EditorFor(x => x.name)
- </div>
- </div>
- @*<script src="~/Scripts/jquery-3.4.1.min.js"></script>*@
- <script type="text/javascript">
- $(document).ready(function () {
-
if i uncomment this below code
Create.cshtml
- <script src="~/Scripts/jquery-3.4.1.min.js"></script>
and comment the below code
BundleConfig.cs
then working fine
but I am trying to add jquery in bundle file then give an error
why I am using bundle.config file because when project run then load the jquery library only at once
that is the reason I am adding bundle.config inside jquery path
If I use script add individually in view page then request load time increase
- <script src="~/Scripts/jquery-3.4.1.min.js"></script>
that is reason I am using bundle.config file