Stopping Javascript / angular watches when app paused

When user leaves application (application goes in background) application still consumes CPU (on android).

I think angular watches/evnethanlders are running.

I can define event handlers for pause and resume events like

document.addEventListener("resume", onResume, false);
document.addEventListener("pause", onPause, false);

But how to stop and resume Javascript execution.??

I found possible solution (keepruning preference)

Yep. This is a problem I’m currently facing – how to make sure HTML5 video playback is paused when the app pauses