Add post delete function and optimized javascript functions