Why is this code duplicated in both index.js and application.js?