[英]How to bundle the JS loaded by script manager from CDN in Asp.Net
I have an application in asp.net, I am using a script manager in master page. 我在asp.net中有一个应用程序,我在母版页中使用脚本管理器。 I want to load all the scripts related to script manager from CDN and hence I have placed EnableCDN="true" in script manager. 我想从CDN加载与脚本管理器相关的所有脚本,因此我在脚本管理器中放置了EnableCDN =“ true”。
<asp:ScriptManager runat="server" EnableCdn="true" />
I have noticed that all the scripts are loaded separately this increases the http requests, I want to bundle all of them into 1 script. 我注意到所有脚本都是单独加载的,这增加了http请求,我想将所有脚本捆绑到1个脚本中。
Has anyone achieved this bundling the scripts loaded from CDN into 1 js file instead of separate in asp.net(Not MVC)? 有没有人实现将CDN加载的脚本捆绑到1个js文件中,而不是将它们捆绑在asp.net中(不是MVC)?
Below is the snap of all js that is getting loaded separately 以下是单独加载的所有js的快照
Only application relative URLs (~/url) are allowed to be included in ScriptBundle
, Using CDN in bundles is supported only at the top bundle level. ScriptBundle
仅允许包含与应用程序相关的URL(〜/ url),仅在顶级软件包级别支持在软件包中使用CDN。
You could upload the entire bundle to a CDN after building it yourself and us it like https://ajax.aspnetcdn.com/ajax/4.6/1/MsAjaxJs.js
. 您可以自己构建,也可以像https://ajax.aspnetcdn.com/ajax/4.6/1/MsAjaxJs.js
那样将整个捆绑包上传到CDN。
bundles.Add(new ScriptBundle("~/bundles/MsAjaxJs", "https://ajax.aspnetcdn.com/ajax/4.6/1/MsAjaxJs.js").Include(
"~/Scripts/WebForms/MsAjax/MicrosoftAjax.js",
"~/Scripts/WebForms/MsAjax/MicrosoftAjaxApplicationServices.js",
"~/Scripts/WebForms/MsAjax/MicrosoftAjaxTimer.js",
"~/Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js"));
Also, optimizations are enabled when compilation is set to false
in web.config
file 此外,在web.config
文件中将编译设置为false
时,也会启用优化
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.