Updated javascript with global constraints.