Jan 10 2007

The JQuery specifics

Posted by admin under ASPCodeHeaderManager

As you might have noticed I am totally hooked on JQuery. As a Javascript library it's fantastic and I have therefore decided to use it for Ajax functionality as well.  

For my experimental project http://www.findfreefonts.net I decided to use it and therefore this ASPCodeHeaderManager control got invented. It started as a way for me to get the document.ready scripts I created in master as well as pages into the same location.

So here is the JQuery specifics:

1. <headermanager:IncludeScript Path="~/scripts/jquery-104.js" HighestCompressionLevel="2" StaticPathLevel1="~/scripts/jquery-104.js" StaticPathLevel2="~/scripts/jquery-104.pack.js" />

i.e use the already compressed files from jquery.com

2. the control has another (so far in these docs not mentioned) collection - JQueryDocumentReadyScripts.

You can define such scripts anywhere you'd like - in master, in specific pages, in design mode - by code - and they will all be injected in a SINGLE document.ready() handler. This handler in turn gets injected into the "globalö" script src tag - meaning you have only one single script tag even in JQuery scenarios - and more importantly - your JQuery scripts will be treated just as other scripts in header - i.e with ScriptsInHeaderCompression you can remove whitespace or pack/obfuscate even that part.

If you view source on http://www.findfreefonts.net you will see that I am using this very control (ASPCodeHeadermanager) and that I am using whitespace removal for the document.ready part etc.