If you "require" a module that has a large amount of code at the top-level scope, that code will be run. If it looped around for 10s, the overhead would be 10s of maxed-out CPU. If it ran a poor database query, the overhead would be slower database performance. If it only defines functions and doesn't actually run code directly, those functions have to be parsed and injected into the running scope of the code that required it. Depending on the number and size of those functions, the overhead will vary. Think of "require" like a "copy&paste" of the module into the code that requires it.


RequireOnce is cheaper because if you have A requires B&C, and B also requires C, with an old "require" you would be "copy&pasting" C twice. RequireOnce would only run the "require" the first time it is encountered.