What are Styles.Render and Scripts.Render?

Style.Render is used to render a bundle of CSS files defined within BundleConfig.cs files. Styles.Render create style tag(s) for the CSS bundle. Like Style.Render, Scripts.Render is also used to render a bundle of Script files by rendering script tag(s) for the Script bundle.

public class BundleConfig
{
	public static void RegisterBundles(BundleCollection bundles)
	{
		bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(		"~/Scripts/jquery.unobtrusive*",
		"~/Scripts/jquery.validate*"));
		bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
		"~/Content/themes/base/jquery.ui.core.css",
		"~/Content/themes/base/jquery.ui.resizable.css",
		"~/Content/themes/base/jquery.ui.selectable.css",
		"~/Content/themes/base/jquery.ui.button.css",
		"~/Content/themes/base/jquery.ui.dialog.css",
		"~/Content/themes/base/jquery.ui.theme.css"));
	}

Styles.Render and Scripts.Render generate multiple style and script tags for each item in the CSS bundle and Script bundle when optimizations are disabled. When optimizations are enabled, Styles.Render and Scripts.Render generate a single style and script tag to a version-stamped URL which represents the entire bundle for CSS and Scripts.

Tagged , . Bookmark the permalink.

Leave a Reply