3 ms·
FWIW, base64-js and similar libraries are still needed (though probably not in this case...) because window.btoa() only works on latin1 ASCII strings. Try givi
by V99 9y ago
FWIW, base64-js and similar libraries are still needed (though probably not in this case...) because window.btoa() only works on latin1 ASCII strings. Try giving it some arbitrary UTF-8:
btoa("\ud83d\ude0b") -> Uncaught DOMException: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.
(Edit: apparently HN doesn't either; changed to \u...)
- josteink 9y ago> FWIW, base64-js and similar libraries are still needed For what? This is a non-interactive text-only website. It shouldn't need anything beside HTML and CSS.
- eadmund 9y agoYou are 100% correct. Honestly, it doesn't need CSS even, although that's nice to have. I've got NoScript on, and now the pages load perfectly. I think I may return to being a CNN reader now. If only they could figure out how to monetise this.
- V99 9y agoFor the rest of the sentence... I was clearly referring to the question of why someone would use a library for base64 versus the built-in function. Not getting involved in the anti-js internet pitchfork mob.