Dan Ehrmann
Top achievements
Rank 1
Dan Ehrmann
asked on 14 Apr 2009, 02:57 PM
I see that jQuery is included with many script downloads for RadControls (it is in the text returned by WebResource script requests). Each time a different page is served with some RadControls, jQuery is included again. I also use jQuery for some other stuff. This means it is then downloaded twice for a page - once for RadControls and once with my script tag.
I don't want my users to have to download it multiple times, and I don't want to have version mismatches between the jQuery I am using and the one included by Telerik.
Can this be remedied somehow? Turning off script combining in the RadScriptManager seems to help, but then there are a lot of separate script downloads.
Is there a way for me to access the embedded jQuery within RadControls so I don't have to use my own script tag and cause multiple downloads?
I don't want my users to have to download it multiple times, and I don't want to have version mismatches between the jQuery I am using and the one included by Telerik.
Can this be remedied somehow? Turning off script combining in the RadScriptManager seems to help, but then there are a lot of separate script downloads.
Is there a way for me to access the embedded jQuery within RadControls so I don't have to use my own script tag and cause multiple downloads?
6 Answers, 1 is accepted
0
Hi Dan Ehrmann,
Please check these blog posts:
I hope the information there will answer your questions.
Kind regards,
Veselin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Please check these blog posts:
I hope the information there will answer your questions.
Kind regards,
Veselin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Dan Ehrmann
Top achievements
Rank 1
answered on 14 Apr 2009, 04:45 PM
Thanx for the info - I was able to use the embedded jQuery without any problems, so that is good
However, I still see jQuery included in every page visit which requires RadControls. Also, the Telerik common code and the MS ajax scripts are included as well. Is there any way to prevent these large script files from being downloaded so many times? (It appears that this happens only on the first visit to a specific page during a session, but even so, it is a lot of repeated script code as users visit different pages.)
However, I still see jQuery included in every page visit which requires RadControls. Also, the Telerik common code and the MS ajax scripts are included as well. Is there any way to prevent these large script files from being downloaded so many times? (It appears that this happens only on the first visit to a specific page during a session, but even so, it is a lot of repeated script code as users visit different pages.)
0
Hi Dan,
This side effect might be related to WebResource caching - when your website is in debug mode (<compilation debug="true" /> in web.config) files streamed by WebResource.axd are not cached by the browser.
Here is a nice blog post on that matter:Ð’
http://ocegtech.blogspot.com/2006/06/aspnet-20-webresourceaxd-and-browser.html
In a word everything should be ok once the site is not in debug mode (<compilation debug="false" />).
Greetings,
Paul
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
This side effect might be related to WebResource caching - when your website is in debug mode (<compilation debug="true" /> in web.config) files streamed by WebResource.axd are not cached by the browser.
Here is a nice blog post on that matter:Ð’
http://ocegtech.blogspot.com/2006/06/aspnet-20-webresourceaxd-and-browser.html
In a word everything should be ok once the site is not in debug mode (<compilation debug="false" />).
Greetings,
Paul
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Dan Ehrmann
Top achievements
Rank 1
answered on 14 Apr 2009, 11:06 PM
I have been using Fiddler to test this stuff. It shows that the scriptresource and webresource files are all publicly cached, even though I am in debug mode. I switched out of debug mode but did not see any change in behavior. (FYI - this is a dev machine, not production - I am running IIS 5 on XP.)
When I set EnableScriptCombine to false, I see multiple requests for various script files on the first page I request. It looks like these files are properly cached. For example, I look for the big MS or Telerik core files and see only one download for them, no matter what other pages I view (which is good). Each page, of course, downloads some more resources that are specific to the controls on that page, but that is ok.
When I set EnableScriptCombine to true, I see a single large script file downloaded for each page. This file includes the big MS files, the Telerik core, and jQuery, plus whatever is specific to the page. If I reload the same page, these files are re-used from cache. However, if I go to another page, they are downloaded again - and again for the first visit to every page.
I suppose this is because the browser is caching based on the url (/webresource.axd?d=...<long string>...). When scripts are combined, each page has a (possibly) unique combination of scripts, and it is the combination which is cached, not the individual parts. With script combination turned off, each script file can be downloaded and cached on its own. So there are more connections (at least at first), but there are some pretty large files that do not need to be downloaded over and over - on some pages, this costs me over 100KB (compressed size!).
The reason I am looking at this is because I am upgrading my old pre-Ajax RadControls to the new stuff. To make things easier, I was looking at putting the ScriptManager control on my container aspx instead of on each ascx file which requires it (my site is a sort-of home-grown master page design). Some ascx files do not require the RadScriptManager control, so I was investigating what it costs in page size and bandwidth to do this. I would not mind if the first page accessed by a user downloaded the common scripts if they were going to be cached and used for all pages. But it doesn't seem to me that the benefit of combining scripts into fewer connections outweighs 100KB+ additional download on each page.
So my thought now is to just put the RadScriptManager on each ascx as needed, and set EnableScriptCombine to false to permit better cache usage. Does this seem reasonable, or am I missing something?
Editing my post with one more comment - I notice that if I load jQuery with RadScriptManager, I get a javascript error: "$telerik.$ is not defined". If I add "Telerik.Web.UI.Common.Core.js", the script error goes away.
When I set EnableScriptCombine to false, I see multiple requests for various script files on the first page I request. It looks like these files are properly cached. For example, I look for the big MS or Telerik core files and see only one download for them, no matter what other pages I view (which is good). Each page, of course, downloads some more resources that are specific to the controls on that page, but that is ok.
When I set EnableScriptCombine to true, I see a single large script file downloaded for each page. This file includes the big MS files, the Telerik core, and jQuery, plus whatever is specific to the page. If I reload the same page, these files are re-used from cache. However, if I go to another page, they are downloaded again - and again for the first visit to every page.
I suppose this is because the browser is caching based on the url (/webresource.axd?d=...<long string>...). When scripts are combined, each page has a (possibly) unique combination of scripts, and it is the combination which is cached, not the individual parts. With script combination turned off, each script file can be downloaded and cached on its own. So there are more connections (at least at first), but there are some pretty large files that do not need to be downloaded over and over - on some pages, this costs me over 100KB (compressed size!).
The reason I am looking at this is because I am upgrading my old pre-Ajax RadControls to the new stuff. To make things easier, I was looking at putting the ScriptManager control on my container aspx instead of on each ascx file which requires it (my site is a sort-of home-grown master page design). Some ascx files do not require the RadScriptManager control, so I was investigating what it costs in page size and bandwidth to do this. I would not mind if the first page accessed by a user downloaded the common scripts if they were going to be cached and used for all pages. But it doesn't seem to me that the benefit of combining scripts into fewer connections outweighs 100KB+ additional download on each page.
So my thought now is to just put the RadScriptManager on each ascx as needed, and set EnableScriptCombine to false to permit better cache usage. Does this seem reasonable, or am I missing something?
Editing my post with one more comment - I notice that if I load jQuery with RadScriptManager, I get a javascript error: "$telerik.$ is not defined". If I add "Telerik.Web.UI.Common.Core.js", the script error goes away.
0
Accepted
Hi Dan Ehrmann,
Indeed RadScriptManager generates different urls for different sets of registered scripts. This is mandatory for the combining phase. If you choose to set EnableScriptCombine to false you might as well use the built-in ScriptManager control as you would get the exactly same behavior (RadScriptManager actually falls back to the default implementation when EnableScriptCombine=false).
The Telerik version of jQuery requires including Core.js. This is by design. More info can be found in this blog post.
Regards,
Albert
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Indeed RadScriptManager generates different urls for different sets of registered scripts. This is mandatory for the combining phase. If you choose to set EnableScriptCombine to false you might as well use the built-in ScriptManager control as you would get the exactly same behavior (RadScriptManager actually falls back to the default implementation when EnableScriptCombine=false).
The Telerik version of jQuery requires including Core.js. This is by design. More info can be found in this blog post.
Regards,
Albert
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Dan Ehrmann
Top achievements
Rank 1
answered on 15 Apr 2009, 11:35 AM
ok, thanx for the info
I had previously read that blog post about jQuery, but completely missed the part of the core scripts being required. Oops!
I had previously read that blog post about jQuery, but completely missed the part of the core scripts being required. Oops!