-1

I am looking for a script that would read through an HTML file (actually a Smarty template file, but that shouldn't matter), parse the paths out of <script></script> and <link/> tags, and use them as input for UglifyJS/UglifyCSS (or other minification software). Bonus points if the script is able to download remote resources as well.

I want to minify my resources in the order they appear within my HTML files without having to manually build the list. Perhaps some gulp plugin could accomplish such a task?

I can write a script to do this myself, but I would rather use something that has been tested and has a substantial community behind it.

Mike Furlender
  • 3,869
  • 5
  • 47
  • 75
  • A pat on the back and a coupon for another pat on the back – Mike Furlender Oct 08 '14 at 14:51
  • 1
    Bonus or not: "Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – Teemu Oct 08 '14 at 14:52
  • I am not looking for the BEST tool, or for opinions on which tool is better. I am simply looking for ANY such tool. – Mike Furlender Oct 08 '14 at 14:54
  • 1
    What task runner are you using? grunt? gulp? something else? grunt has usemin that will do this for you. – Kevin B Oct 08 '14 at 18:33
  • Currently I am not using a task running. I am using a file watcher in my development environment to do those types of tasks. I will check out usermin. – Mike Furlender Oct 08 '14 at 18:53

1 Answers1

1

Apologies if you meant only in JS.

Heres a bit of sed:

sed -n "s/<\(script\|link\)\+.*\(href\|src\)=\"\([^\'\"]*\)\".*/\3/p" <filename>

Will return the value of the href or source in a script or link tag in a file.

byrnedo
  • 1,415
  • 10
  • 12