javascript refactoring to get jquery into footer.