Might need to be careful: there's actually a URL-safe variant of base64 [0] that might be better, although the problematic + and / characters are probably not actually problematic within a fragment (+ only means space within the query, and / only means folder within a path and if a server wants it to) in which case standard base64 could be fine.

The example with the coffee bean background image already uses base64 for the image data, so I guess that would get double-encoded.

[0] https://medium.com/@bagdasaryanaleksandr97/understanding-bas...