Remove unnecessary function from javascript