views:

214

answers:

3

I use jsmin to compress my javascript files before uploading them to production.

Since I tend to have one "code-behind" javascript file per page, I wind up doing this a lot.

I installed a Windows Powertoy that adds a context menu item in Windows Explorer, so I can "Open Command Window Here". When I click that, the command prompt opens up in the right directory. That saves a little bit of typing.

However, I still have to type something like:

jsmin <script.js> script.min.js

To get it to work. This is a hassle.

I'd like to create a context menu item that will allow me to right-click on a *.js file and select "jsmin-compress this file." Then jsmin would be invoked, and the original file would be compressed into "original_filename.min.js"

How can I do this?

A: 

you could drop a link to a batch script into the user sendto directory. Something like

jsmin %1 script.min.js

which is what I usually do

Andrew Cox
A: 

You could do it using a batch file and Open With...

  Set jsminPath="C:\SomePath\jsmin.exe"
  %~d1 
  CD %~d1%~p1 
  %jsminPath% "%~n1.js" "%~n1.min.js"
Nescio
+1  A: 

Here is how to add an entry to your context menu for .js files:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JSFile\shell\JSMinify]
@="JSMinify" 

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JSFile\shell\JSMinify\Command]
@="cmd.exe /c \"implement whatever cmd-friendly functions you want here (can use %1 and %%f) "
duckyflip