Hacker News new | ask | show | jobs
by rich_harris 3212 days ago
The CSS developer experience is just one small aspect of the framework. The advantages are spelled out more fully in [this blog post](https://svelte.technology/blog/frameworks-without-the-framew...) — Svelte compiles your components to lean, very fast JavaScript. It handily outperforms React, and your app will almost certainly be smaller and start quicker.

You're unlikely to find a postcss plugin that can eliminate dead code. Unless it can analyse your CSS in the context of your markup, it has no way of knowing what's safe to remove. For that, you need statically analyzable single file components.

1 comments

No reason why Webpack/`import css` couldn't eliminate the CSS from this

    // styles.css
    .root { background: grey; }
    .button { border: 1px solid blue; }
    .error { color: red }
    .alert { background: red }

    // Component.css
    import styles from './styles.css'

    return (
      <div className={styles.root}>
        <button className={styles.button}>Submit</button>
        {false && <div className={styles.error}>Error!</div>}
      </div>
    )
Both the .error and .alert are candidates for being removed.

Of course, I'm not aware of any solution for nothing this currently, but all the bits and pieces are there for it to be feasible.