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?
You can use a ScriptManager/ScriptManagerProxy control and define the scripts in the CompositeScript section/property. See MSDN reference.
<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.
Combres does bundling, versioning, minification and caching of JavaScript and CSS resources. It's very configurable and performant.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With