Better JavaScript handling