开发者

Managing JavaScript dependencies with CDN in ASP.NET

Generally speaking, individual JavaScript files that a page uses should be combined into a single filed and minified. To this end, we have an AssetController.ScriptTag() that's used like this:

<%= ScriptTag
(
    "/js/global.js",
    "/js/accounts.js",
    "/js/googmaps.js"
)%>

The output of this method is a single URL that returns a single, minified file from a GET. This worked great until we decided that we needed put our resources like .js and .css files on a CDN. Now, we need to generate these combined, minified JS files at build time, and push the results to the CDN.

How do most people ac开发者_开发知识库complish this--how do they incorporate the generation of these files into their build and deploy?


The YUI Compressor for .Net is a popular choice. It allows you to combine and minify Javascript (and CSS is you want).

This article shows, step by step, how to use the YUI compressor during the build process.

http://yuicompressor.codeplex.com/wikipage?title=Visual%20Studio%20Post-build%20Event%20example&ProjectName=yuicompressor

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜