0

The goal: Output the file size of HTML snippet returned from a fetch() call in JavaScript.

Response from fetch request

{
 content: "<p>Image Long html code block within this property</p>"
}

How would I calculate the size of content property, whether in KB or MB? How can I achieve this in JavaScript?

VLAZ
  • 26,331
  • 9
  • 49
  • 67
Samuel
  • 5,529
  • 5
  • 25
  • 39
  • Does this answer your question? [How to calculate Content-Length in JavaScript](https://stackoverflow.com/questions/17762778/how-to-calculate-content-length-in-javascript) – devlin carnate Jun 09 '22 at 19:09
  • [An answer on "How many bytes in a JavaScript string?"](https://stackoverflow.com/a/52254083/14956277): `new Blob([response.content]).size`. – D M Jun 09 '22 at 19:16

0 Answers0