1

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

1 Answer 1

2

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.

1
  • Thank's @Brett.
    – PЯINCƎ
    Commented Jun 13, 2017 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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