.NET Blog

Tony Cavaliere

 
My Favourite Albums
  And the Grappa wins.
E-mail me Send mail

Disclaimer

Hey unlike other bloggers I stand by what I say but just in case. The opinions expressed herein are my own except on Tuesday when the second card is not turned up otherwise it ain't worth squat.

© Copyright 2012

Minify Javascript and use the <CompositeScript> tag

I've been looking into improving the performance of a web site that I'm working on and decided to experiment with JavaScript minification and the asp.net <CompositeScript> tag. What exactly does <CompositeScript> actually do? Does it merely combine the Javascript files that appear within the tag or does it also minify them? If it does minify them how good a job does it do?

I decided to look at four scenarios;

  1. Use the Javascript files as is, that is, no <CompositeScript> and no  minification.
  2. Use the Javascript files as is but with the <CompositeScript> tag.
  3. Minify the Javascript files using jsmin but with no <CompositeScript> tag
  4. Minify the Javascript files using jsmin and include the <CompositeScript>.

The jsmin tool can be downloaded from here. It's a command line tool and is rather simple to use.

The following listing contains the Javascript files I used to test with. As you can see the majority of the files are jQuery and jQuery plug-ins. The only exception is the custom master.js file.

   27     <Scripts>

   28       <asp:ScriptReference Path="~/js/jquery-1.3.2.js" />

   29       <asp:ScriptReference Path="~/js/jquery-blockUI.js" />

   30       <asp:ScriptReference Path="~/js/jquery-timers.js" />

   31       <asp:ScriptReference Path="~/js/jquery-valid8.js" />

   32       <asp:ScriptReference Path="~/js/master.js" />

   33     </Scripts>

In the first scenario we inject the Javascript as is with no minification or combining. The resulting size of the Javascript files is shown in the following figure. I used Firebug to obtain this listing.

Max  no CompositeScript  

The total size of the five Javascript files is 147KB.

In the second scenario we use the <CompositeScript> Tag and this markup is shown in the listing below.

   27     <CompositeScript>

   28       <Scripts>

   29         <asp:ScriptReference Path="~/js/jquery-1.3.2.js" />

   30         <asp:ScriptReference Path="~/js/jquery-blockUI.js" />

   31         <asp:ScriptReference Path="~/js/jquery-timers.js" />

   32         <asp:ScriptReference Path="~/js/jquery-valid8.js" />

   33         <asp:ScriptReference Path="~/js/master.js" />

   34       </Scripts>

   35     </CompositeScript>

And the output from Firebug is show here. Notice that the five Javascripts have been combined into a single resource and is only 47KB. Is <CompositeScript> minifying the Javascript? Not really, after examining the Headers from Fiddler it appears that the size reduction is a result GZIP. I've included the outpit from Fiddler as well.

Max with CompositeScript

gzip

The question still remains will minification of the Javascript files prior to composing result in any performance gains.

In scenario 3 we minify the Javascript files using jsmin and remove the use of the <CompositeScript>. The Firebug results are shown here.

Min  no CompositeScript

The total size of the five Javascript files is 75KB.

The last scenario involves minifying the Javascript files using jsmin and also including the <CompositeScript> tag. The Firebug results are shown below.

Min with CompositeScript    

Incredible we are now down to 28KB. It appears that there is an advantage to performing minification prior to using the <CompositeScript> tag. Again as before the <CompositeScript> is compressing the Javascript using GZIP. We starting with a Javascript payload of 147KB and reduced it down to 28KB. Minify your Javascript prior to using the <CompositeScript> tag.

One last point I should make is that I only used jsmin to minify jquery-blockUI.js, jquery-timers.js, jquery-valid8.js and master.js. I downloaded the official minimized version of jquery-1.3.2.js from the jQuery site.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by CynotWhyNot on Monday, March 09, 2009 6:22 AM
Permalink | Comments (49) | Post RSSRSS comment feed

Related posts

Comments

Hits Tech Gadgets us

Friday, March 13, 2009 11:03 AM

Hits Tech Gadgets

yes, its completely available

answerspluto.com

Monday, July 13, 2009 10:18 PM

pingback

Pingback from answerspluto.com

list of urls - 5 « Answers Pluto

designer bag US

Thursday, May 27, 2010 2:34 PM

designer bag

Comfortabl y, the article is in reality the best on this valuable topic. I harmonise with your conclusions and will thirstily look forward to your coming updates. Just saying thanks will not just be sufficient, for the wonderful clarity in your writing. I will instantly grab your rss feed to stay privy of any updates. Fabulous work and much success in your business dealings!

Cross cutting shredder us

Saturday, October 02, 2010 6:41 PM

Cross cutting shredder

Wow, man, this is the best =)

Tips to make your eyes beautiful us

Sunday, October 03, 2010 2:37 AM

Tips to make your eyes beautiful

Thanks for posting this. i really had good time reading this.

garnier nutrisse us

Tuesday, October 05, 2010 12:18 PM

garnier nutrisse

mrgnyrwajumhryd, <a href="http://stearnsandfoster.org">stearns and foster</a>, ReNrjsbRLJfwLNVFGUDw.

Compact refrigerator us

Wednesday, October 06, 2010 3:35 PM

Compact refrigerator

Hey =) that was some good reading =)

Cross cutting shredder us

Wednesday, October 06, 2010 8:32 PM

Cross cutting shredder

Wow, man, this is the best =)

mattress topper us

Thursday, October 07, 2010 1:38 PM

mattress topper

mchtivpbwnmoerhbnkof, http://1800mattress.org 1800 mattress , eijdKnYUfPgSAaqWsB. iuvcwcekhjrlumlmaunc, http://honorar.si zaposlitev , SesnxfEQBCFGwaDyrV.

C 17 Globemaster III Over Alaska HD Wallpaper us

Friday, October 08, 2010 2:21 AM

C 17 Globemaster III Over Alaska HD Wallpaper

Its a pity you dont have a donate button, i would donate some =)

sports supplements us

Tuesday, October 12, 2010 10:27 AM

sports supplements

fjqlxpsgujmcelnoxn, http://www.bestsportsupplement.co.uk , JWsotPebjxunuEJKpsjw.

dropship supplements us

Tuesday, October 19, 2010 9:04 AM

dropship supplements

brqqeiyxeucvmpxejx, http://www.physique-wholesale.com , txIKOhbwreFexdLQitQM.

Facebook statuses us

Saturday, October 23, 2010 8:52 PM

Facebook statuses

Hey check out my blog too. I hope i have some fun stuff too

Shriya HD Wallpaper us

Sunday, October 24, 2010 10:12 AM

Shriya HD Wallpaper

Its a pity you dont have a donate button, i would donate some =)

Cross cutting shredder us

Sunday, October 24, 2010 8:45 PM

Cross cutting shredder

I loved this post

Gyaru inspired hairtutorial us

Monday, October 25, 2010 5:41 PM

Gyaru inspired hairtutorial

Thanks for posting this. i really enjoyed reading this.

Ciara 12 HD Wallpaper us

Tuesday, October 26, 2010 6:33 AM

Ciara 12 HD Wallpaper

Hey check out my blog too. I hope i have some interesting stuff too

Emo us

Wednesday, October 27, 2010 11:49 AM

Emo

This site is great. i visit here evaryday.

Compact refrigerator us

Thursday, October 28, 2010 1:43 AM

Compact refrigerator

Thanks for posting this. i really enjoyed reading this.

Cross cutting shredder us

Thursday, October 28, 2010 11:41 AM

Cross cutting shredder

Great site design!!!! Whattheme did you use?

Moonshine us

Thursday, October 28, 2010 10:24 PM

Moonshine

Great site design!!!! Whattheme did you use?

Opi my private jet 0 5 oz us

Friday, October 29, 2010 9:14 AM

Opi my private jet 0 5 oz

Its a pity you dont have a donate button, i would donate some =)

Poker strategy tips the value bet us

Friday, October 29, 2010 4:52 PM

Poker strategy tips the value bet

I liked this post

American Actress Jessica Simpson HD Wallpaper us

Thursday, November 25, 2010 3:55 PM

American Actress Jessica Simpson HD Wallpaper

Hey check out my blog too. I hope i have some interesting stuff too

Facebook statuses us

Friday, November 26, 2010 5:47 AM

Facebook statuses

Great site design!!!! Whattemplate did you use?

Emo us

Friday, November 26, 2010 10:29 AM

Emo

Hey check out my blog too. I hope i have some interesting stuff too

Compact refrigerator us

Friday, November 26, 2010 3:15 PM

Compact refrigerator

This site is great. i visit here evaryday.

Nail Toe Fungus us

Friday, November 26, 2010 6:37 PM

Nail Toe Fungus

I admire the valuable information you offer in your articles. I will bookmark your blog and have my children check up here often. I am quite sure they will learn lots of new stuff here than anybody else!

Cross cutting shredder us

Friday, November 26, 2010 8:12 PM

Cross cutting shredder

Thanks for posting this. i really had good time reading this.

Victorias secret beauty rush lip gloss grapefruit blast us

Saturday, November 27, 2010 1:29 AM

Victorias secret beauty rush lip gloss grapefruit blast

Its a pity you dont have a donate button, i would donate some =)

Before they are hanged us

Saturday, November 27, 2010 6:48 AM

Before they are hanged

Thanks for posting this. i really enjoyed reading this.

Angelina jolie hairstyles and beautiful updo hairstyle for angelina jolie

Its a pity you dont have a donate button, i would donate some =)

Aishwarya Rai HQ HD Wallpaper us

Monday, December 06, 2010 2:01 AM

Aishwarya Rai HQ HD Wallpaper

Great site design!!!! Whattemplate did you use?

Facebook statuses us

Tuesday, December 07, 2010 3:02 AM

Facebook statuses

I loved this article

Emo us

Tuesday, December 07, 2010 8:43 AM

Emo

Thanks for posting this. i really enjoyed reading this.

Compact refrigerator us

Wednesday, December 08, 2010 2:15 AM

Compact refrigerator

This site is cool. i visit here evaryday.

Cross cutting shredder us

Wednesday, December 08, 2010 8:26 AM

Cross cutting shredder

Thanks for posting this. i really enjoyed reading this.

Cool water by zino davidoff for women eau de toilette spray 3 4 oz

Where can i find your rss? I cant find it

Storm glass us

Thursday, December 09, 2010 8:30 AM

Storm glass

Great site design!!!! Whattheme did you use?

The talisman us

Thursday, December 09, 2010 3:02 PM

The talisman

Where is your rss? I cant find it

Estero beach hotel resort us

Friday, December 10, 2010 3:43 AM

Estero beach hotel resort

I loved this article

T mobile tap phone review part 1 us

Friday, December 10, 2010 9:20 AM

T mobile tap phone review part 1

Thanks for posting this. i really had good time reading this.

Facebook statuses us

Sunday, December 12, 2010 11:53 PM

Facebook statuses

Where is your rss? I cant find it

Compact refrigerator us

Tuesday, December 14, 2010 5:00 AM

Compact refrigerator

Great site design!!!! Whattheme did you use?

Cross cutting shredder us

Tuesday, December 14, 2010 1:58 PM

Cross cutting shredder

Great site design!!!! Whattemplate did you use?

Acid Reflux Causes ca

Saturday, December 18, 2010 4:40 PM

Acid Reflux Causes

Nice Website. You should think more about RSS Feeds as a traffic source. They bring me a nice bit of traffic.

How to download cs hack bad boy v5 us

Sunday, December 26, 2010 12:10 AM

How to download cs hack bad boy v5

I loved this post

Life lessons facebook statuses us

Sunday, December 26, 2010 9:30 AM

Life lessons facebook statuses

This site is great. i visit here evaryday.

latest iphone jo

Thursday, January 20, 2011 7:50 PM

latest iphone

Would you be interested in exchanging links?