One can think at first at the base64 encoding, and base64 data-uri.
But is it the most space efficient solution?
My use case is to store tiny captcha images aside clickable links, which are gif or png files, 500-2000 bytes in size, somehow embedded in the utf8 HTML source.
I am thinking of data- attributes of the clickable links to store the appropriately encoded image data. Then I would like to use JavaScript to decode the embedded image into a dinamically set base64 data-uri.