I\'m using this function to convert a file size in bytes to a human-readable file size:
function getReadableFileSizeString(fileSizeInBytes) { var i = -1;
Another example similar to those here
function fileSize(b) { var u = 0, s=1024; while (b >= s || -b >= s) { b /= s; u++; } return (u ? b.toFixed(1) + ' ' : b) + ' KMGTPEZY'[u] + 'B'; }
It measures negligibly better performance than the others with similar features.