Tool To Read Html File And Save All Javascripts Found Into One?
Solution 1:
Yes there is, if you don't mind introducing a dependency on Grunt (and Node.js) for your build step. Using grunt-usemin will allow you to introduce build comment blocks into your HTML, like so:
<!-- build:js dist/master.min.js -->
<script src="vendor/jquery.js"></script>
<script src="vendor/underscore.js"></script>
<script src="lib/base.js"></script>
<!-- endbuild -->
You can read more about usemin on https://github.com/yeoman/grunt-usemin, and here's a nice article from Chris Coyier introducing Grunt: http://24ways.org/2013/grunt-is-not-weird-and-hard/
I'm not sure if there's an automated way of doing this without build comments, but you could always write your own if there's not one already available (the plugin directory for Grunt is massive, with new plugins being added every day).
Solution 2:
Phantomjs is a headless scriptable browser that could easily be made to do what you want.
You'd need to write a short javascript file to direct it to load a page, download all the script files and concatenate them into a single local file to write out.
You'd probably also have to sideload a javascript minification library and use that to compact your file.
Post a Comment for "Tool To Read Html File And Save All Javascripts Found Into One?"