The modern web development ecosystem is currently undergoing a radical transformation. With the rapid maturation of CSS features like Container Queries, the :has() selector, and native nesting, developers are finding it easier than ever to delete sprawling JavaScript logic in favor of a few elegant, declarative lines of CSS. It is the dream of every front-end engineer: a green diff, a performance boost, and the satisfaction of "doing more with less."
However, as Gabriel Shoyombo explores in his recent analysis, this trend toward "CSS-first" development carries a hidden, systemic risk. Replacing JavaScript with modern CSS features can simplify a specific component while simultaneously making the wider application significantly harder to reason about. The danger lies not in the CSS itself, but in how these new features interact with the complex, established ecosystems of existing code.
The Illusion of Simplicity: Main Facts
When we replace a ResizeObserver with a container query, we are not merely refactoring; we are shifting the responsibility of application logic from the imperatively controlled JavaScript runtime to the browser’s declarative rendering engine.
While the pull request might show a reduction in line counts—often represented by a sea of red deletions—the underlying complexity is rarely destroyed. It is merely relocated. Like a new, quiet roommate moving into a shared apartment, a new CSS feature must navigate the existing "housemates": the component layout, the CSS Cascade, and the browser’s internal rendering pipeline. If the new feature is not introduced to the existing rules of the house, it can inadvertently disrupt the stability of the entire system, leading to bugs that are notoriously difficult to track down.
A Chronology of the "Refactor Trap"
The lifecycle of a failed migration often follows a predictable, disheartening pattern:

- The PR Approval: A developer identifies a block of JavaScript—perhaps an observer managing a responsive layout—and replaces it with a concise
@containerquery. The diff is clean, the PR is approved by lunch, and the team celebrates the reduction in bundle size. - The Silent Regression: A week later, symptoms emerge. A dashboard card vanishes, headings shift unexpectedly on tablets, or spacing within nested elements becomes inconsistent.
- The Debugging Nightmare: Because the changes were made in CSS, standard JavaScript debugging tools like breakpoints and
console.logare useless. Developers find themselves searching for the culprit, only to realize the "bug" isn’t a coding error, but an architectural side effect of the new CSS rule. - The Realization: The team discovers that the new CSS property (such as
container-type) has triggered a Block Formatting Context (BFC) or altered the Cascade in ways they hadn’t anticipated, creating a conflict with legacy styles that were never intended to coexist with these modern features.
Supporting Data: When Systems Collide
The complexity of modern CSS is often misunderstood as a "coding issue" rather than a "systemic issue." Data from recent performance tests reveals that seemingly harmless CSS rules can create significant bottlenecks when combined.
In a controlled experiment involving 5,000 rows of data, the performance cost of a single :has() selector was negligible (under 1.5ms). However, when that selector was combined with a secondary, unrelated rule in the same stylesheet, the browser was forced to restyle all 5,001 elements upon every toggle. The result was a 31ms delay—nearly two full frames—on every interaction.
This demonstrates that while CSS is often faster than JavaScript, its performance characteristics are opaque. Neither rule in the test looked suspicious in isolation, and neither explicitly mentioned the other, yet their interaction created a "performance footgun" that would be invisible to most standard code reviews.
Official Perspectives and Community Discourse
The debate surrounding this shift is intense. In April 2026, Igor Roztropiński published an essay titled “Modern Frontend Complexity: Essential or Accidental?”, challenging the industry to reconsider whether our approach to browser evolution is actually making the web simpler.
The response from the developer community has been polarized. On platforms like Reddit, many argue that "less code" is simply an aesthetic preference that masks underlying complexity. Others point out that CSS-in-JS and other abstractions have historically introduced their own layer of unpredictable behavior, suggesting that the problem is not the technology, but the lack of holistic architectural planning.

As Shoyombo notes, the consensus is emerging: A native CSS feature only reduces complexity when it successfully replaces existing logic without disrupting the surrounding environment.
Implications: The Six-Question Migration Checklist
If we are to navigate this era of modern CSS responsibly, we must move away from the "greenfield" mindset. Most of the code we ship is part of an existing, aging migration, not a fresh, clean start. To ensure that a refactor truly improves the system, developers should address the following questions before merging any CSS-heavy pull request:
- Who is the owner? Does this behavior have two owners (e.g., legacy JS and new CSS)? If so, how will they coordinate?
- What side effects are triggered? Does this property create a new Block Formatting Context or change containment behavior that might collapse existing elements?
- How does it impact the Cascade? Does this new rule inadvertently override or get overridden by unlayered legacy styles?
- Is the selector too broad? Does the use of
:has()or nesting reach into child components that shouldn’t be affected? - What is the performance footprint? Have you measured the impact of these new selectors across a large DOM tree?
- Have we finished the job? If we are replacing JavaScript, have we fully deleted the observer, the old classes, and every reference to the previous implementation?
Conclusion
Modern CSS is a powerful evolution for the web, providing capabilities that were once the exclusive domain of complex JavaScript libraries. However, power demands discipline. The goal of front-end engineering is not merely to delete code, but to build resilient, maintainable systems.
When you find yourself deleting more than you add, take a moment to pause. Enjoy the red lines, certainly, but then interrogate the empty space. Ensure that your new CSS "tenant" has been properly introduced to the household. By treating CSS migrations as a systemic architectural task rather than a simple line-count reduction exercise, we can harness the power of modern web standards without sacrificing the stability of our applications. As the saying goes: if you cannot answer the hard questions about how your code interacts with the wider system, the migration is not yet complete.

