I have a JavaScript file that registers validators for a form validation library I\'m using. These validators become accessible through that library, so I don\'t need to imp
It depends on the context, are you working on Node.JS? If so, there's a [caching native feature] (https://nodejs.org/docs/latest/api/modules.html#modules_caching) that allows to cache the JS file the first time is invoked, no matter how many times is written. if not you could create a Singleton using closures. That will make sure it just runs once.
1: es6 way
import lib from './lib';
2: you could leave it on main.js, but if it feels awkward, put it in a separate util JS file and import that one.