Related question is here (but no answer). I wanna return the size of HTML loaded through XMLHttpRequest. And I cache files for 30 minutes. So I did save the files in a temporary folder say temporary_folder/filename.html. And I am able to get the size of this file using filesize(filename-here)
. But the fact is this just returns the size of HTML code inside this. This HTML file also contains images using <img>
tag. And how can I get the entire size of these? In brief I wanna size of the filename.html + sizes of (images inside).
function updateProgress (event)
{
var percentComplete = ((event.loaded/event.total)*100);
$('#progress-bar').val(percentComplete);
$('#progressbar-value').text(percentComplete);
}
This is how I update the progress bar and show the percentage loaded. But this is updated with the size of the HTML file and not with sizes of images included in it. Say 5 KB (filename.html). This filename.html contains some big images sizing 3 or 4 MB for example, so the progress bar ends faster than the actual loading time.
Any ideas to resolve this?
EDIT:
After reading one of the answers here while building the HTML file I kept track of the sizes of images and added the total size to the filename. But then arises a new issue. In the PHP side I set the Content-Length
with the total size. But now on the client side, the HTML loads first and then the images are rendered. So there is a mismatch in the progress bar filling again. Also I see the following error in the console
Uncaught NotSupportedError: The implementation did not support the requested type of object or operation. (anonymous function)
w.extend.each
w.fn.w.each
w.fn.extend.val
updateProgress