I want to know what the js function stopObserving() is used for.


Say you have a form input where you are observing the keyUp event. If you wanted to no longer listen to this event, maybe because the value passes validation or is no longer required to validate due to other form values, you would call stopObserving on that elements keyUp observer to no longer listen to this event.

The main reason is to help keep the footprint of the JavaScript small. Especially if you have lots of dynamic elements and are doing lots through JavaScript. Not listening for an event can help save fractions of time and keep your site feeling snappy and responsive to inputs.

| improve this answer | |
  • Thank's @Brett. – PЯINCƏ Jun 13 '17 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.