Consider the work done by a force that acts on an object as the object moves from an initial position to a final position along any arbitrarily chosen path. If this work is the same for all such paths, we call the force a conservative force. If the work is not the same for all paths, we call the force a nonconservative force.

(Physics 5th Edition, Resnick, Halliday, Krane, page 275)

For example, gravity is a conservative force. No matter what path you take, the Work done will always be:

On the other hand, friction is not a conservative force. If you take a short path, the work done by friction is smaller than if you took a long path.

Thought differently, if you move up, then return down again under the force of gravity, the work done will be zero, so it is a conservative force. If you go somewhere and then go back again while there is friction, the work done by friction will be non-zero,

Mathematically:

Or: