Is there a reason for not placing this particular piece of code in a js file (like for most other cases)?