OC-5819 Performance issue due to unnecessary repeated generation of JS

https://jira.openclinica.com/browse/OC-5819