Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Editor: use debounce instead of timeout #95

Open
shailendher opened this issue Mar 8, 2017 · 0 comments
Open

Editor: use debounce instead of timeout #95

shailendher opened this issue Mar 8, 2017 · 0 comments

Comments

@shailendher
Copy link

shailendher commented Mar 8, 2017

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant