What is in the gravitational field that is making the work done independent of path taken? I could not understand the same path independence in electric field. So I am trying to understand it first in gravitational field and then apply it to electric field.
 A: The gravitational (and Electric) fields are vector fields that are conservative. The main idea behind a conservative field is that work done is independent of path. Another way to state the same thing is to say that work done along any closed path is zero. Since work is defined as line integral of field of Force with respect to $dr$, where r parametrizes the curve  , we can say that
$$ \oint_c \overrightarrow F \cdot  d\overrightarrow r  = 0 $$where c is a closed curve. 
There is a theorem called the Curl theorem (also called Stokes theorem). It states that if S is an oriented smooth surface, and C is a closed smooth boundary curve, then $$ \iint_S \nabla \times \overrightarrow F \cdot  d \overrightarrow s = \oint_C \overrightarrow F \cdot  d\overrightarrow r $$F is a vector field.
We can conclude that is $\nabla \times \overrightarrow F=0$ Then $ \oint_c \overrightarrow F \cdot  d\overrightarrow r  = 0$. So the property that a field must have for it to be conservative is $\nabla \times \overrightarrow F=0$
It isn't difficult to show that both the Electric and Gravitational Fields have this property. 
