move javascript to frontend