The trick TiddlyWiki does with data URLs (IIRC?) (https://tiddlywiki.com/#Saving%20with%20the%20HTML5%20saver) seems pretty close to me.