section scripts vs script-tag in asp.net mvc -
what difference of both statements concerning section scripts , script-tag? not content inside scripts not interest me.
@section scripts { @scripts.render(bundles.scripts.validation) } vs
<script src="@url.content("~/scripts/validation.js")"></script>
the first one renders <script> tag have @rendersection("scripts") in layout.
this is preferred when don't have include script pages.
also @scripts.render minify , bundle scripts. used at end of body tag views can scripts after dom rendered.
the second one remains use <script> tag.
if use in layout, script included in pages (e.g. jquery).
let's take example
<!-- html in layout, before scrip --> @renderbody() <script src="@url.content("~/scripts/jquery.min.js")"></script> @rendersection("scripts") <!-- html after script --> here, if script make use of jquery want included section because jquery included before section.
if include <script> in view give error, jquery missing, because included before jquery.
Comments
Post a Comment