3 ms·
It would be great if the browser makers adopted something similar to SingleFile as a standard to replace MIME HTML. Though I think SingleFile should be updated
by russellbeattie 4y ago
It would be great if the browser makers adopted something similar to SingleFile as a standard to replace MIME HTML. Though I think SingleFile should be updated a bit to take advantage of new APIs to make the output page cleaner.
With a small bit of JS at the top of the page (or provided by the browser), all the assets could be included are the bottom of the page in an organized JSON blob containing the base64 encoded files, and the rest of the page could remain untouched. The JS simply intercepts the elements as they are parsed and swaps out the src/hrefs for the appropriate data urls below. By adding in a super restrictive CSP to the top of the page, it's guaranteed to be safe and private to open. Here's a prototype:
https://www.hypertext.plus/demo/htmldoc-test1.html https://www.hypertext.plus/demo/htmldoc-test1.html
- gildas 4y agoI agree that browsers should offer an API in order to get all the resources easily. It would make things much easier. However, for security reasons, this API would still be restricted to environments like Web Extensions or automation tools like Playwright. FYI, I also took another approach which might interest you, see https://github.com/gildas-lormeau/SingleFileZ https://github.com/gildas-lormeau/SingleFileZ. The main drawback is that the HTML produced by SingleFileZ is not valid (but tolerated by the HTML5 spec.).