Reputation: 4019
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.
Upvotes: -1
Views: 341
Reputation: 1465
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.
Upvotes: 1