Pulled javascript apart into components