console log total filesize of all mp3s

Hunter
Sunday, November 2nd, 2025 at 7:17 PM

script.js+6-1

script.js
 30  let currentPreloadIndex = 0;
 31  let priorityPreloadQueue = []; // Songs requested by user that need priority preloading
 32  let isPreloadingPriority = false;
 33 +let totalBytesLoaded = 0; // Track total filesize of all preloaded songs
 34  
 35  // Load tracks from tracks.json
 36  fetch('tracks.json')

716  
717  function preloadNextSong() {
718  	if (currentPreloadIndex >= songs.length) {
    -		console.log('All songs preloaded');
719 +		const totalMB = (totalBytesLoaded / 1024 / 1024).toFixed(2);
720 +		console.log(`All songs preloaded - Total size: ${totalMB} MB (${totalBytesLoaded} bytes)`);
721  		return;
722  	}
723  

747  			return response.blob();
748  		})
749  		.then(blob => {
750 +			// Add blob size to total
751 +			totalBytesLoaded += blob.size;
752 +
753  			// Create a blob URL that will persist in memory
754  			const blobUrl = URL.createObjectURL(blob);
755