为什么Scripts.Render调用JsMinify.Process? [英] Why Scripts.Render invoke JsMinify.Process?

查看:140
本文介绍了为什么Scripts.Render调用JsMinify.Process?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我异型我的 ASP.NET MVC 应用程序,我看到了一个奇怪的函数调用。

I profiled my ASP.NET MVC application and I saw strange a function calls.

您可以看到它在图像

总是在MVC呈现布局我们调用 system.web.optimization.scripts.render 其中调用 JsMinify.Process Minifier.MinifyJavaScript ,但我想应该是什么样的微小一次上开始应用。

Always when mvc render layout we invoke system.web.optimization.scripts.render which invoke JsMinify.Process and Minifier.MinifyJavaScript, but I thought what minification should be one time on the start app.

我说得对不对?

也许我必须设置一些优化设置呢?

Maybe must I set some settings for optimization it?

条件:


  • 本地主机

  • 发布

  • BundleTable.EnableOptimizations = TRUE;

推荐答案

大问题!

直观地说,你是对的,应该在应用程序执行资产的微小的启动。您认为资产相同传递给所有的浏览器。但微软相信很多JS的这和CSS的浏览器特有的。

Intuitively, you are right, minification of assets should be performed on application Startup. You assume that assets are delivered identically to all browsers. But Microsoft believes that much of JS and CSS is browser specific.

如果您检查asp.net网站上的 ASP.NET 4.5 <参考href=\"http://www.asp.net/web-forms/tutorials/hands-on-labs/whats-new-in-aspnet-and-web-development-in-visual-studio-2012#Exercise4\"相对=nofollow>捆绑和微小 后,他们专门状态:

If you check asp.net site's reference on ASP.NET 4.5 Bundling and Minification, they specifically state:

捆绑和缩小在ASP.NET 4.5运行时执行,因此
  该过程可以识别用户代理(例如IE浏览器,Mozilla的,
  等),因此,通过靶向用户浏览器提高玉米pression
  (例如,去除的东西,是Mozilla的特定时
  请求来自IE)。

Bundling and minification in ASP.NET 4.5 is performed at runtime, so that the process can identify the user agent (for example IE, Mozilla, etc) , and thus, improve the compression by targeting the user browser (for instance, removing stuff that is Mozilla specific when the request comes from IE).

什么缓存?

捆绑不如迟钝一个异形会对你的想法。如果你看到了 MVC 4捆绑和缩小 的参考,他们指出:

Bundling isn't as obtuse as a profiled would have you think. If you look up MVC 4 Bundling and Minification reference, they point out:

捆绑缓存

捆绑设置HTTP Expires头一年,自当是捆绑
  创建。如果您导航到pviously查看页面$ P $,提琴手显示IE
  不会使束一个条件请求,也就是说,有
  没有HTTP GET从IE的捆绑,并没有HTTP响应304请求
  从服务器

Bundles set the HTTP Expires Header one year from when the bundle is created. If you navigate to a previously viewed page, Fiddler shows IE does not make a conditional request for the bundle, that is, there are no HTTP GET requests from IE for the bundles and no HTTP 304 responses from the server.

这是比你需要更多的信息,但信息是,JSMinify对相关缓存缩小的资产检查。

This is far more information than you need, but the message is that, JSMinify has a check for relevant cached minified assets.

当您在另一个因素,我们已经在使用我们的资产的缩小的版本(例如jquery.min.js,jQuery的-ui.min.js),可以AP preciate即净缩小是一个补充过程。

When you factor in further that we already use minified version of our assets (eg jquery.min.js, jquery-ui.min.js), you can appreciate that .Net minification is a supplemental process.

为什么所有类型的微小要发生

Why does Minification of all types have to happen

这篇关于为什么Scripts.Render调用JsMinify.Process?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆