jsonresume / registry-server

This repo is deprecated in favor of https://github.com/jsonresume/registry-functions
https://github.com/jsonresume/registry-functions
MIT License
95 stars 46 forks source link

Editor: use debounce instead of timeout #95

Open shailendher opened 7 years ago

shailendher commented 7 years ago

Currently, the editor triggers an event on every keypress and this results in an multiple ajax calls and also bad user experience. (especially in the online editor) lib.js: form.on("input", "input, textarea", function() { form.trigger("change"); }); main.js: form.on("change", function() { clearTimeout(timer); preview.addClass("loading"); timer = setTimeout(function() { var data = builder.getFormValues(); form.data("resume", data); postResume(data); }, 200); });

While there are probably many ways to optimize this, one option is to use _.debounce (lodash library is already part of lib) to rate limit the ajax requests.

I currently don't have vagrant setup but if there is enough interest I could make a pull request for this change.