javascript auto save input
var saveTimeoutId;
document.addEventListener("DOMContentLoaded", () => {
// Get the element(s) you want to autosave
let area = document.getElementById('area');
// use keyup over keypress so that backspaces will register
area.addEventListener('keyup', () =>{
// clear save timeout as the user is editing
if (saveTimeoutId) window.clearTimeout(saveTimeoutId);
// Store the timeout id again
saveTimeoutId = window.setTimeout(() =>{
...
// Code for saving here
...
}, 1000); // Configure timeout period to preference
});
});