Skip to content
Advertisement

Image file size from data URI in JavaScript

I am not sure it’s even possible but – can I get the image file size from data URI?

For example, let’s say there is an IMG element where src goes:

JavaScript

Based on the src, can I get the image file size by using plain JavaScript? (without server request)

Advertisement

Answer

If you want file size, simply decode your base64 string and check the length.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement