What is the difference between "@Scripts.Render" and "<script>"?

Scripts.Render is used for bundling, if you bundle multiple scripts together and give them a name, then you can render them all together using this statement.

On debug mode, they'll render multiple tags, and in production you can deploy a single bundled script. Debug mode is set true or false in the web.config:

  <system.web>
    <compilation debug="true" ... />

Here is more about bundling.


Functionally, they both have the same result in your example. The Scripts.Render is part of the System.Web.Optimization namespace, which is included in the Microsoft.AspNet.Web.Optimization NuGet package. As such, Scripts.Render also support JavaScript bundles (see http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification).

Tags:

C#

Asp.Net

Razor