Update scripts.js

Read the comments for explanation