I'm wondering if there's an existing (Linux) tool/command to make a HTML file more "standalone" by automatically inlining third-party resources (JS and CSS).
I'm using a tool which generates HTML reports, and these reports contain references to third-party CSS (Bootstrap) and JS (jQuery). These resources don't work if the page is accessed via file://
, due to security restrictions. They work when served from a HTTP server, but that's obviously not ideal when the files are local to the machine.
So far I've created a script to find/replace these particular URLs with data URIs of their content. This works for now, but is a maintenance burden due to everything being hard-coded.
Is there a more reliable/standard way to achieve a similar effect? I can think of a few ways to do this: creating data URIs (like my script), writing the content into the style/script elements, or replacing the URLs with relative paths to local copies. Any of these would be fine. Ideally I could just do something like:
$ inlineHtmlResources < existingFile.html > standloneVersion.html