optimizing code

code optimizing and jsHint fixes. Still has ie8 bug. Script now silently doesn't do anything if it can't reach DOM before page appears.