Giacomo Balli profile picture
Giacomo Balli
Tech Entrepreneur | Advisor | Consultant

I help business owners navigate and leverage technology.

Let's Chat

Get API or File Size

This code sample will allow you to retrieve the size of a file or API response without actually downloading it (server needs to provide Content-Length header).

function getApiSize(url) {
    var req = new XMLHttpRequest();"HEAD", url, false);

- Call getApiSize(url); and you will see the size in your console.

This snippet focuses on iOS development. Make sure to verify/adapt any vendor prefixes. Back to main listing.

Published: Mon, 11 Jan 2016 02:48:03 +0000