I want to store images and sounds using JS. Is there any API for this, like the localstorage? Unfortunatly in the localstorage I can only save text.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
While you could store files manually (with Google Chrome’s File API), the intended approach is caching. Cache is a straightforward way to store your media seemingly automatically.
It’s only a matter of writing a manifest:
After the first load of these files, you just load them again as usual, but they come from the disk instead of your server. It works when the browser is off-line, too.
It also degrades nicely: unsupported browsers would simply manage the cache as they see feet.
Here’s a tutorial by Google at HTML5Rocks.