Wrap in a closure so we don't leak global vars

In javascript the only 'scope' comes from functions.  Previously you were 'leaking' `appended`, `w`, and `onscroll` into the global scope.  If other code on the page tried to use those vars, #badthings might have happened.  To be more sanitary, we wrap the whole thing in a function which we immediately call.