Why this matters
The production reason.
Imports should be boring. If importing a module starts timers, reads the DOM, or sends analytics, it becomes harder to test and split.
Keep modules focused on exported values and functions. Run startup work explicitly from the place that owns it.
This makes bundling, lazy loading, and server/client boundaries easier to reason about.
// analytics.js
export function initAnalytics() {
window.analytics?.load();
}
// app.js
import { initAnalytics } from "./analytics";
initAnalytics();