Hello everybody, for those of you interested, please check out the following blog post that shows a YouTube video with a small summary of the presentation I have given.
Hello everybody. Thank you for the people who attended my presentation yesterday. Please find attached the material from the presentation. This includes the PowerPoint presentation itself + the latest release of AdvancedScriptManager.
Hello everybody, those of you who followed up my sss.aspx posts, should note that this server control is the successor to sss.aspx.
AdvancedScriptManager to the rescue. AdvancedScriptManager helps you with all these problems/optimizations with minimal effort from you. Read on to know what it does.
- AdvancedScriptManager is a Server side control that has support for design time. You add it by simply dragging it from your Tools toolbar.
- For it to function properly, the control needs to add an HttpHandler to your Web.Config files. In design time, it will detect that it is missing and prompt you to add it automatically for you.
- You add one or more scripts to it by using the designer, if the file you add is not found, it will be highlighted in red. This is a typical look of the control:
- The script files that you add to the control will be combined at runtime and streamed back as one file only, minimizing requests. Moreover the file is sent back using GZip compression if the browser supports it.
- The combined file that is sent to the browser has the proper Response headers set to support smart cashing. It supports the ETag and the Modified-Since headers. The control will properly handle the responses with 304 errors when the files are not changed, the browser will not download the files again.
- The dependency management feature goes as follows: Each file that depends on another file, will have a comment at the beginning of the file that indicates the proper dependency. Take a look at script1.js, script2.js and script3.js in the sample provided, script3 depends on script2 and script2 depends on script1 and script1 depends on jquery. Here is how the comment would look like:
/// <AdvancedScriptManager include="/scripts/jquery-1.2.6.js"/>
Do not worry if you re-include base scripts, for example script3 depends on script2 and script1. But script2 already includes script1. If you reinclude script1 in script3 you will not have a problem. The control builds a proper dependency list based on all the comments in the script files it has and handles the order properly. Moreover, if you have more than one control on the page, say 1 in the head of the page and another in the body. If you include a script file in the first control, and you include it in the second control as well by mistake or due to dependencies, it will not be injected again, all of the controls on the same page track the injected files and will not reinject the same file again when it is already injected. I use the HttpContext.Current.Items to enable the controls on the same page to be “aware” of each other at runtime.
In design time, when you add scripts to the control, the control will show you the full list of the files it will inject based on the dependencies of the files, this will help you detect problems in dependencies if you included the wrong files. You also have a property in design time “ShowFullDependencies” which can be toggled on and off to show the actual files added to the control or the full list of dependency files.
There is another design time property “ShowInDesign” that is on by default. When it is on, you will see the control as the screen shot above. If you want to see your page design without the control interfering with the final look, set this property to off and the design time control will not be visible.
If your project has virtual path providers, you can add support to them in this control by hooking the event OnGetFile.
Let me know if you have any comments and have fun speeding up your website :)
Download the sample application + code from here
Hello all, I wanted to write some filters on a query I had and I needed to compare some datetime variables, but only the time part of the datetime and not the full datetime value. I realized there is no built in function in MS Sql Server to isolate or separate the time field out of a datetime value or the date field out of a datetime value. I googled some solutions on the internet and non of them gave me the quick simple solution I needed so I decided to approach the problem with a simple solution. I wrote two functions called GetTimeOnly and GetDateOnly and they serve a simple purpose, to isolate the time or date out of a datetime value.
Here is the sql code for them.
create function GetTimeOnly(@val datetime)
IF (@val is null)
cast(datepart(hh,@val) as varchar(2)) + ':' +
cast(datepart(mi,@val) as varchar(2)) + ':' +
cast(datepart(ss,@val) as varchar(2)) + '.' +
cast(datepart(ms,@val) as varchar(4))
create function GetDateOnly(@val datetime)
if (@val is null)
cast(datepart(yyyy,@val) as varchar(4)) + '-' +
cast(datepart(mm,@val) as varchar(2)) + '-' +
cast(datepart(dd,@val) as varchar(2))
Its usage is simple and straight forward, instead of using the datetime variable directly in an sql query, just put it in the function that you need, for example:
select dbo.GetTimeOnly(getdate()) as TimeOnly, dbo.GetDateOnly(getdate()) as DateOnly
Now using functions like DateDiff or comparing with “>”
becomes very easy.
It's been a while since I posted here, mainly because my hardisk crashed on me on the 31st of December it could not make it till the coming year. After the crash and a new hardisk, I decided to upgrade to Windows XP, I had vista before and Life is Great again :) I had some trouble finding the drivers, but eventually I found everything I need... Some simple differences to note, VS2008 took around one hour to install on XP. SP1 of VS2008 took less than 30 minutes to install, I remember I had to wait hours to finish installing SP1 when I had Vista... Makes you wonder what is it doing?! Mind you that when I had Vista, all the graphics effects were stripped down to gain maximum performance, most unnecessary services were stopped but still it was extremely slow compared to XP. Hopefully Windows 7 will be much better. Within the near future I will be giving a presentation at Microsoft offices in Lebanon on speeding up your WebApplications. I will keep you posted.
Please check this post, it is the successor to this post. Thank you.
I have updated sss.aspx to include a couple of more features and here is what it can do for you now.
- The most important benefit is it allows you to combine several script files (CSS or js) into one file to return to your client, this helps increase performance of your website by minimizing the http requests the page requires.
- The returning stream tries to use GZip compression if supported by the client browser. This further increases load speeds of your site.
- You can specify default script files to include always.
- Proper cashing headers and proper generation of 302 response codes (not modified) to minimize the transfer of scripts to the client browser. Script files are sent back to the client browser only if they have been modified. Two headers are processed to achieve this, "If-Modified-Since, Last-modified" and "If-None-Match, ETag".
To use sss.aspx, it is very simple.
1. add the file sss.aspx it to your site (no need to recompile).
2. instead of including your script files like this:
Add this now.
Note how the file common.js was omitted from the list, this is because the files sample.js and engine.js start with the comment:
/* <sss include="common.js"/> */
This comment will make sss.aspx combine the file common.js with sample.js and engine.js in the proper order and serve them back as one file.
If you have any comments, please let me hear about them. I tried to be straight to the point in this post, if some things are not clear enough, let me know and I will gladly explain more. You can use fiddler2 (http proxy debugger) to check the results of using sss.aspx.
Another important tip for increasing your site's load speeds is to enable "Content Expiration" in IIS.
Download the latest sss.aspx file here