seajs的动态压缩
来源:互联网 发布:网络安全技术与应用 编辑:程序博客网 时间:2024/06/05 14:43
base: '/Bundle/js/',comboSyntax: ['?', ','],当运行seajs配置问题后,会启动响请求,Bundle控制器,去压缩js文件#region js压缩合并 class CacheItem { public string Content { set; get; } public DateTime Expires { set; get; } } [HttpGet] [IsPostedFromThisSite] [CacheFilter(CacheProfile = "DefaultLong")] public ActionResult js(string path, string v) { string tail = Request.QueryString[null]; string cacheKey = path + tail; CacheItem cacheItem = HttpRuntime.Cache.Get(cacheKey) as CacheItem;//服务端缓存 if (cacheItem == null) { path = "~/Scripts/" + path; StringBuilder notMinifiedJs = new StringBuilder(); string tempfile = Server.MapPath(path); if (IO.File.Exists(tempfile)) { notMinifiedJs.Append(IO.File.ReadAllText(tempfile, Encoding.UTF8)); } else { if (tail != null) { foreach (var item in tail.Split(new string[] { ",", ";", "|" }, StringSplitOptions.RemoveEmptyEntries)) { string temppath = Server.MapPath(path + item); if (IO.File.Exists(temppath)) { notMinifiedJs.Append(IO.File.ReadAllText(temppath, Encoding.UTF8)); } } } } var minifier = new Minifier(); var minifiedJs = minifier.MinifyJavaScript(notMinifiedJs.ToString(), new CodeSettings { EvalTreatment = EvalTreatment.MakeImmediateSafe, PreserveImportantComments = false });#if !DEBUG cacheItem = new CacheItem() { Content = minifiedJs, Expires = DateTime.Now.AddDays(1) }; HttpRuntime.Cache.Insert(cacheKey, cacheItem, null, cacheItem.Expires, TimeSpan.Zero);#endif return JavaScript(minifiedJs); } else { return JavaScript(cacheItem.Content); } } #endregion
0 0
- seajs的动态压缩
- 一种基于gulp对seajs的模块做合并压缩的方式
- seaJs学习笔记之seaJs的准备
- spm打seajs压缩包摘抄
- seajs 的api接口
- Seajs的用法
- Seajs的组装控件
- seajs的那些事儿
- seajs的使用
- seajs的模块标识
- SeaJS的简单使用
- seajs 的API
- seajs遇到的问题
- seajs的使用
- seajs常用的API
- 我的seajs实例
- 动态 HTTP 压缩的问题
- 状态压缩的动态规划
- python核心模块——urllib模块
- 字符与字节及字符流与字节流的区别
- HDU 2614 Beat
- jQuery.artDialog用法(弹窗)
- 卡特兰数
- seajs的动态压缩
- javascript基础笔记一函数
- [部署篇8]VMWare搭建Openstack——计算节点的Neutron安装
- 20150411C++文件流
- 如何获取Spinner里item的值
- Objective-c NSPathUtilities.h常用路径工具、函数和方法
- Yii2 使用九 join关联表查询
- 湖南多校对抗赛(2015.03.28)
- Java 中提高性能的几个技巧