JavaScript event handler management optimization

Taking care of event handlers getting removed properly.

Change-Id: Iba4ec003494ad1d1fe36d8142d9a8873711b81ed
Merge "JavaScript event handler management optimization"