Move common JavaScript to shared file