In MVC4
, Views have script
elements included at the bottom of the page.
Eg. In _layout.cshtml
(under Shared
folder), <script>
tags are placed at the very bottom. While I understand that this makes the page load faster, the problem is actually this:
In my Views
, sometimes I happen to use some scripts like autocomplete
, something like below:
<script type="text\javascript">
......
</script>
which is not functional because scripts
tag are included at the very end of the page. (JQuery is not even loaded at that time)
Painfully, I had to move the Script Bundle rendering
to the top of the page. Like,
render jquery first
then load scripts
so, am I missing something or I should always keep my scripts
tag at the top of the _layout.cshtml
page ?
Thanks for your responses.