开发者

ASP.NET, combining conditionally included script files

开发者 https://www.devze.com 2022-12-18 11:53 出处:网络
We are working on an ASP.NET CMS project using jQuery as the basis for our client side scripting. The jquery-1.2.6.js file is the only script file that is always included. Other script files are cur

We are working on an ASP.NET CMS project using jQuery as the basis for our client side scripting.

The jquery-1.2.6.js file is the only script file that is always included. Other script files are currently included depending on what components the CMS editor is using on a page or page开发者_StackOverflow中文版 template.

A lot of the script combiners produce a static script. If we took that approach we would have to add all possible script files in just in case they were needed. We are not currently using any of the ASP.NET Ajax extensions so have not looked at what that may give us.

Anyone got any suggestions?

I have read Combining and Caching multiple JavaScript files in ASP.net but I don't think that covers off the conditional nature of our situation

So great I can use ScriptManagerProxies and some methods on the base master Page. However there is one other thing. Stopping all the ASP.NEt Ajax guff being sent down to the client. I am going to take a look at bleroy's hack until ASP.NEt 4.0 releases

TIA

Pat Long


Working in Sitecore on a site that had multiple scripts for different pages, we created a list of script items in Sitecore, then added a Multlilist field to the Items. We had a placeholder in the head of the master page, and dynamically added the scripts as they appeared in the multilist field. We did the same thing with CSS as well. It worked out nicely. (Specifically, it was on http://www.utulsa.edu)

Edit: I misunderstood what you originally meant. It seems like you may need combine and produce all the possible static scripts you need, then dynamically include the one you are looking for, if you're looking for only one script include per page.

Otherwise, you could just depend on caching to keep your script requests down, and do what you are currently doing

Edit 2: A third thought is you could write your own combiner that will combine scripts on demand, and include the generated (or pre-generated) script


I don't know if this will help you or not, but Scott Hanselman posted on twitter that you could download issues of MSDN Magazine for free. I followed the link and looked through a couple of issues and this month (Feb, 2010), and one of the first articles discusses predictive fetching with jQuery and ASP.NET Ajax.

This looks like it could be along the lines of what you're looking for. As far as stopping the AJAX requests, I haven't read the entire article, but I'd assume it mentions something in there (as predictive fetch would have to account for this).

0

精彩评论

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

关注公众号