3

I have defined a bundle:

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                        "~/Scripts/jquery-1.8.3.min.js"));

My layout looks like this:

<!DOCTYPE HTML>
<html lang="en-US" dir="ltr">
<head id="ctl00_Head1">
    <title>Test</title>
    @*<script src="@Url.Content("~/Scripts/jquery-1.8.3.min.js")" type="text/javascript"></script>*@
    @Scripts.Render("~/bundles/jquery")
</head>
<body id="UCG">
    @RenderBody()
    <script type="text/javascript">
        $(document).ready(new function () {
            alert('test');
        });
    </script>
</body>
</html>

My View is minimal and insignificant. I have no idea why ASP.MVC (4) doesn't load jQuery using bundles while commented, standard

2
  • try not to use the minified version of jQuery Commented Sep 4, 2014 at 11:39
  • 1
    What makes you think its not being loaded? Commented Sep 4, 2014 at 11:44

2 Answers 2

6

include the unminified version (jquery-1.8.3.js). As bundles already minify files, it doesn't work if they are already minified

Sign up to request clarification or add additional context in comments.

2 Comments

he can also write like this: "~/Scripts/jquery-{version}.js" then it will be using "normal" version in debug and minified in release and he will be able to upgrade jquery without changing code
Thank you very much! Very surprising and worth knowing.
1

Replace

$(document).ready(new function () {
            alert('test');
        });

With (new keyword is not required here)

$(document).ready(function () {
            alert('test');
        });

1 Comment

It works with new, although thank you for your advice.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.