How to build a new Release script after modifying the source code

Coordinator
Jan 15, 2008 at 6:24 PM
Edited Jan 16, 2008 at 5:01 AM
Someone recently asked me how we are combining our Debug source scripts into a single Release script (Scripts/Release/Slide.Show.js). We use Packer, Dean Edwards' excellent JavaScript compression tool. Specifically, the steps are:

  1. Modify the source code as desired (i.e. anything in the Scripts/Debug folder)
  2. If you are using source control, check out the scripts in the Scripts/Release folder
  3. Execute the Release.bat file (located in the Solution Items folder) to create a consolidated version of the Scripts/Release/SlideShow.js file
  4. Copy and paste the contents of Scripts/Release/SlideShow.js into Packer
  5. Check the Base62 encode and Shrink variables options in Packer, and then click the Pack button
  6. Copy the compressed JavaScript results from Packer back into the Scripts/Release/SlideShow.js file
  7. If you are using source control, check in the scripts in the Scripts/Release folder
Packer is great because it compresses our 200K of JavaScript into approximately 50K. It also makes deployment of Slide.Show easier because the control only requires one script tag (in addition to Silverlight.js, of course). One day, if Slide.Show gets big enough, we'll want to think about excluding unnecessary scripts to minimize download size, but for now 50K seems quite reasonable.

Note that Packer is unforgiving when it comes to missing semicolons -- it will generate invalid JavaScript in those cases. So if you're modifying source code, make sure you are dotting and crossing your I's and T's.
Sep 18, 2008 at 4:52 PM
I followed these directions and repacked the version of the scripts that comes in the tip release download, no code changes, I just wanted to verify this would work before I started making changes....it doesn't work for me.  In Firefox, the first load of the control will give me a control but it's clearly missing most of the xaml and refreshing that page gives me nothing.  In IE 7 I just always get nothing.  If I look at the generated source in IE it's just the parent div with no object inside.  It seems like the onload event is not getting fired after CreateObject...any ideas?  If I switch back to the packed version of SlideShow.js that comes with the download it works fine so it would seem it's not my Sliverlight.js.  Which leads me to believe the version of the scripts that were used to create the packed version that comes in the most recent download are not the same as the versions of the unpacked scripts in the Debug directory included with the download.