I'm jealous of the rails guys. They can do this:
我嫉妒铁杆人。他们可以这样做:
<%= javascript_include_tag "all_min" %>
... and I'm stuck doing this:
......我坚持这样做:
<script src="/public/javascript/jquery/jquery.js" type="text/javascript"></script>
<script src="/public/javascript/jquery/jquery.tablesorter.js" type="text/javascript"></script>
<script src="/public/javascript/jquery/jquery.tablehover.pack.js" type="text/javascript"></script>
<script src="/public/javascript/jquery/jquery.validate.js" type="text/javascript"></script>
<script src="/public/javascript/jquery/jquery.form.js" type="text/javascript"></script>
<script src="/public/javascript/jquery/application.js" type="text/javascript"></script>
Are there any libraries to compress, gzip and combine multiple js files? How about CSS files?
是否有任何库可以压缩,gzip和组合多个js文件? CSS文件怎么样?
9 个解决方案
#1
6
Also have a look at this article on codeproject:
http://www.codeproject.com/KB/aspnet/HttpCombine.aspx
另请参阅有关codeproject的这篇文章:http://www.codeproject.com/KB/aspnet/HttpCombine.aspx
#2
8
You can use a ScriptManager/ScriptManagerProxy control and define the scripts in the CompositeScript section/property. See MSDN reference.
您可以使用ScriptManager / ScriptManagerProxy控件并在CompositeScript部分/属性中定义脚本。请参阅MSDN参考。
<asp:ScriptManager runat="server">
<CompositeScript>
<Scripts>
<asp:ScriptReference Path="~/public/javascript/jquery/jquery.js" />
<asp:ScriptReference Path="~/public/javascript/jquery/jquery.tablesorter.js" />
<asp:ScriptReference Path="~/public/javascript/jquery/jquery.tablehover.pack.js" />
<asp:ScriptReference Path="~/public/javascript/jquery/jquery.validate.js" />
<asp:ScriptReference Path="~/public/javascript/jquery/jquery.form.js" />
<asp:ScriptReference Path="~/public/javascript/jquery/application.js" />
</Scripts>
</CompositeScript>
</asp:ScriptManager>
It doesn't necessarily clean up the markup any, but it does zip them together.
它不一定能清理标记,但它会将它们压缩在一起。
#3
4
Combres does bundling, versioning, minification and caching of JavaScript and CSS resources. It's very configurable and performant.
Combres对JavaScript和CSS资源进行捆绑,版本控制,缩小和缓存。它非常易于配置和高效。
#4
3
<%= javascript_include_tag "all_min" %>
That really has all the semantics of a classic asp function call, even if it's really ruby. In fact, not knowing any ruby I can still be pretty confident with the guess that this is just a function and "all_min" refers to a folder name that's being passed in as an argument.
这真的具有经典的asp函数调用的所有语义,即使它真的是红宝石。事实上,不知道任何红宝石我仍然可以非常自信地猜测这只是一个函数而“all_min”指的是作为参数传递的文件夹名称。
Since the <%= %>
bee-stings are just a short-cut for Response.Write
in classic ASP, we can conclude that you ought to be able to build your own function that does essentially the same thing and returns a string with the relevant includes.
由于<%=%>蜜蜂只是经典ASP中Response.Write的捷径,我们可以得出结论,你应该能够构建自己的函数,它基本上做同样的事情并返回一个字符串相关的包括。
#5
1
You can do this using an HTTP handler. Check out this blog post from Mads Kristensen:
您可以使用HTTP处理程序执行此操作。看看Mads Kristensen的这篇博客文章:
Combine multiple stylesheets at runtime
在运行时组合多个样式表
#6
1
ScriptManager is under BSD licenece and this I dislike :(. You may see a very good alternative how this is implemented in KiGG's approach:KiGG
ScriptManager属于BSD licenece,我不喜欢这样:(。你可能会看到一个非常好的选择,它是如何在KiGG的方法中实现的:KiGG
The idea behind is that the control allows you to join the files js from web config by separating them into categories(you enlist their names ) pretty simple yaeh. good luck.
背后的想法是,控件允许您通过将文件js分成几类(您登记他们的名字)非常简单来加入来自web配置的文件js。祝你好运。
#7
0
A lot of solutions out there do this with an http handler that dynamically creates a crushed js or css file per a page is not a good idea. It is better to crush your entire sites js and css files into one file and rather serve that. This way the browser loads it once and its cached. All further requests just load from cache. Dynamically crushed js and css files create a file per page. So you might be re-serving the same css and js files for every page.
很多解决方案使用http处理程序执行此操作,每个页面动态创建压缩的js或css文件并不是一个好主意。最好将整个站点的js和css文件压缩成一个文件而不是服务它。这样浏览器就会加载一次并缓存它。所有进一步的请求只从缓存加载。动态压缩的js和css文件每页创建一个文件。因此,您可能会为每个页面重新提供相同的css和js文件。
You can then let the web server serve the crushed css/js file. Most web server. IIS implements kernel mode caching, which is the fastest way to serve any static file.
然后,您可以让Web服务器提供压缩的css / js文件。大多数Web服务器。 IIS实现内核模式缓存,这是提供任何静态文件的最快方式。
If you want a performant, scalable solutions that works in web farms check out:
如果您需要在Web场中运行的高性能,可扩展的解决方案,请查看:
http://code.google.com/p/talifun-web/wiki/CrusherModule
http://code.google.com/p/talifun-web/wiki/CrusherModule
#9
-3
That is a helper method in rails.
这是rails中的辅助方法。
passing it :all will include the default protoype libaries.
传递它:所有将包括默认的原型类型库。
ASP.net MVC tried to copy rails but you can never get the internal asthetics right.
ASP.net MVC试图复制rails,但你永远无法获得正确的内部美学。
My Advice:
我的建议:
Instead of copying everything good from open source just use the real stuff i.e. rails
而不是从开源复制好的东西,只需使用真正的东西,即rails
#1
6
Also have a look at this article on codeproject:
http://www.codeproject.com/KB/aspnet/HttpCombine.aspx
另请参阅有关codeproject的这篇文章:http://www.codeproject.com/KB/aspnet/HttpCombine.aspx
#2
8
You can use a ScriptManager/ScriptManagerProxy control and define the scripts in the CompositeScript section/property. See MSDN reference.
您可以使用ScriptManager / ScriptManagerProxy控件并在CompositeScript部分/属性中定义脚本。请参阅MSDN参考。
<asp:ScriptManager runat="server">
<CompositeScript>
<Scripts>
<asp:ScriptReference Path="~/public/javascript/jquery/jquery.js" />
<asp:ScriptReference Path="~/public/javascript/jquery/jquery.tablesorter.js" />
<asp:ScriptReference Path="~/public/javascript/jquery/jquery.tablehover.pack.js" />
<asp:ScriptReference Path="~/public/javascript/jquery/jquery.validate.js" />
<asp:ScriptReference Path="~/public/javascript/jquery/jquery.form.js" />
<asp:ScriptReference Path="~/public/javascript/jquery/application.js" />
</Scripts>
</CompositeScript>
</asp:ScriptManager>
It doesn't necessarily clean up the markup any, but it does zip them together.
它不一定能清理标记,但它会将它们压缩在一起。
#3
4
Combres does bundling, versioning, minification and caching of JavaScript and CSS resources. It's very configurable and performant.
Combres对JavaScript和CSS资源进行捆绑,版本控制,缩小和缓存。它非常易于配置和高效。
#4
3
<%= javascript_include_tag "all_min" %>
That really has all the semantics of a classic asp function call, even if it's really ruby. In fact, not knowing any ruby I can still be pretty confident with the guess that this is just a function and "all_min" refers to a folder name that's being passed in as an argument.
这真的具有经典的asp函数调用的所有语义,即使它真的是红宝石。事实上,不知道任何红宝石我仍然可以非常自信地猜测这只是一个函数而“all_min”指的是作为参数传递的文件夹名称。
Since the <%= %>
bee-stings are just a short-cut for Response.Write
in classic ASP, we can conclude that you ought to be able to build your own function that does essentially the same thing and returns a string with the relevant includes.
由于<%=%>蜜蜂只是经典ASP中Response.Write的捷径,我们可以得出结论,你应该能够构建自己的函数,它基本上做同样的事情并返回一个字符串相关的包括。
#5
1
You can do this using an HTTP handler. Check out this blog post from Mads Kristensen:
您可以使用HTTP处理程序执行此操作。看看Mads Kristensen的这篇博客文章:
Combine multiple stylesheets at runtime
在运行时组合多个样式表
#6
1
ScriptManager is under BSD licenece and this I dislike :(. You may see a very good alternative how this is implemented in KiGG's approach:KiGG
ScriptManager属于BSD licenece,我不喜欢这样:(。你可能会看到一个非常好的选择,它是如何在KiGG的方法中实现的:KiGG
The idea behind is that the control allows you to join the files js from web config by separating them into categories(you enlist their names ) pretty simple yaeh. good luck.
背后的想法是,控件允许您通过将文件js分成几类(您登记他们的名字)非常简单来加入来自web配置的文件js。祝你好运。
#7
0
A lot of solutions out there do this with an http handler that dynamically creates a crushed js or css file per a page is not a good idea. It is better to crush your entire sites js and css files into one file and rather serve that. This way the browser loads it once and its cached. All further requests just load from cache. Dynamically crushed js and css files create a file per page. So you might be re-serving the same css and js files for every page.
很多解决方案使用http处理程序执行此操作,每个页面动态创建压缩的js或css文件并不是一个好主意。最好将整个站点的js和css文件压缩成一个文件而不是服务它。这样浏览器就会加载一次并缓存它。所有进一步的请求只从缓存加载。动态压缩的js和css文件每页创建一个文件。因此,您可能会为每个页面重新提供相同的css和js文件。
You can then let the web server serve the crushed css/js file. Most web server. IIS implements kernel mode caching, which is the fastest way to serve any static file.
然后,您可以让Web服务器提供压缩的css / js文件。大多数Web服务器。 IIS实现内核模式缓存,这是提供任何静态文件的最快方式。
If you want a performant, scalable solutions that works in web farms check out:
如果您需要在Web场中运行的高性能,可扩展的解决方案,请查看:
http://code.google.com/p/talifun-web/wiki/CrusherModule
http://code.google.com/p/talifun-web/wiki/CrusherModule
#8
#9
-3
That is a helper method in rails.
这是rails中的辅助方法。
passing it :all will include the default protoype libaries.
传递它:所有将包括默认的原型类型库。
ASP.net MVC tried to copy rails but you can never get the internal asthetics right.
ASP.net MVC试图复制rails,但你永远无法获得正确的内部美学。
My Advice:
我的建议:
Instead of copying everything good from open source just use the real stuff i.e. rails
而不是从开源复制好的东西,只需使用真正的东西,即rails