1. A computer implemented method of detecting global variables in JAVASCRIPT code, and adding local variables in place of said global variables, comprising: receiving by a processor a JAVASCRIPT code containing at least one of a plurality of globally defined functions; generating by the processor at least one call flow graph for each one of said at least one of globally defined functions; generating by the processor an inter-procedural control flow graph for each one of said call flow graph; generating by the processor an inter-procedural dominator graph for each one of said inter-procedural control flow graph; identifying by the processor each of referenced global variables within each of said inter-procedural dominator graph and determining a JAVASCRIPT scope of each of referenced global variables; identifying by the processor at least one of: one or more confined global variables which receive a value within a first JAVASCRIPT scope of each referenced global variable wherein said value is not referenced outside of said first JAVASCRIPT scope, and one or more repeating global variables accessed repeatedly within a second JAVASCRIPT scope of each referenced global variable; and automatically adding by the processor local variables in place of at least one of said confined global variables and said repeating global variables.