only load javascript when needed