Get started with filesize CDN

BSD-3-Clause licensed

Filesize.js is a lightweight library for displaying human-readable file sizes.

  • file
  • filesize
  • size
  • readable
  • file system
  • bytes
  • diff

Stable version


How to start using filesize CDN

<!DOCTYPE html>
    <title>Get started with filesize CDN -</title>
    <script src=""></script>
    <input type="file" id="fileInput" accept=".txt, .pdf">
    <button id="calculateButton">Calculate File Size</button>
    <p id="fileSizeResult"></p>

        const fileInput = document.querySelector('#fileInput');
        const calculateButton = document.querySelector('#calculateButton');
        const fileSizeResult = document.querySelector('#fileSizeResult');

        calculateButton.addEventListener('click', () => {
            Filesize.load((filesizeApi) => {
                filesizeApi.loadFile(fileInput.files[0], (errors, fileSize) => {
                    if (errors) {
                        console.error('Error calculating file size:', errors);
                    fileSizeResult.textContent = `File size: ${fileSize.size} bytes`;

All versions