Move some variables inits outside of the functions in js