捆绑vs缩小,哪个是最好的 [英] Bundle vs Minification,Which one is the best

查看:103
本文介绍了捆绑vs缩小,哪个是最好的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道以下哪种方法更好.

I would like to know about which one of the following way is better.

捆绑css文件,然后使用:

Bundle the css files and then use :

 bundles.Add(new StyleBundle("~/BootStrap/css").Include(
                        "~/BootStrap/css/bootstrap.css",
                        "~/BootStrap/css/bootstrap-responsive.css"));

OR

直接使用* .min文件如下:

Use *.min file directly is as below :

<link href="~/BootStrap/css/bootstrap.min.css" rel="stylesheet" />
<link href="~/BootStrap/css/bootstrap-responsive.min.css" rel="stylesheet" />

我希望能在性能方面以及最佳实践方面做出解释.

I would expect the explanation for performance wise and also as best practices.

推荐答案

捆绑是更好的方法,因为它不仅可以缩小所包含的文件,而且还可以将它们打包在一个资源中,该资源可以转换为对服务器的一个请求,而不是多个请求.每个文件.

Bundling is better because it not only minifies the included files but it packages them together in one resource which translates to one request to the server instead of multiple requests, one for each file.

就最佳实践而言,使用捆绑是MVC约定的一部分,因此我认为该方法是最佳实践.

In terms of best practice, using Bundling is part of the MVC convention so I would consider that approach to be best practice.

这篇关于捆绑vs缩小,哪个是最好的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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