Move compatibility functions to compatibility.js and add two more.

Some cleanup in js.js and added two functions for IE 8 compatibility.
@bartv2 @Raydiation @georgehrke