moving JS to the PHP side