JavaScript event handler management optimization

Taking care of event handlers getting removed properly.

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