If the work done by a force depends on the initial and final states and not on the path taken, it is called a conservative force. Gravitational force is a conservative force, as the work done by this force is zero in a round trip i.e., the total work done in travelling certain height and falling back to the same place is zero. While work done by a non - conservative force depends upon the path length. For example, work done by friction force.
W = F S cosθ