Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minifying HTML

Tags:

html

minify

I've googled around but can't find any HTML minification scripts.

It occurred to me that maybe there is nothing more to HTML minification than removing all unneeded whitespace.

Am I missing something or has my Google Fu been lost?

like image 661
Teifion Avatar asked Jan 21 '09 18:01

Teifion


1 Answers

If you have installed node.js and you are a windows user you can create this .bat It will minify all html in your folder in the min subfolder.

The output will be in min folder

  1. open the console. run--> npm install html-minifier -g
  2. create the .bat. don't forget to change the route in cd command. It's easier to change the folder in the bat file than copy and paste.
  3. go in console into the .bat folder and run it.

cd the_destination_folder

dir  /b *.HTML > list1.txt

for /f "tokens=*" %%A in (list1.txt) do html-minifier --collapse-whitespace --remove-comments --remove-optional-tags %%~nxA  -o min\%%~nxA 

pause
like image 152
gensn Avatar answered Oct 05 '22 13:10

gensn