Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server-side apis get all stylesheet at once (maybe it should only get the "current") #516

Open
davesnx opened this issue Oct 21, 2024 · 0 comments
Labels
feature New feature

Comments

@davesnx
Copy link
Owner

davesnx commented Oct 21, 2024

This isn't a big issue and more like an optimisation, where we could only append to the stylesheet the current classNames being used.

We could introduce Stylesheet.collect to analyse the html as a string, and compare the classnames.
Making sure the "critical" is the required to be appended to the resultant HTML.

let stylesheet = Stylesheet.get_all();
let html = ReactDOMServer.renderToString(<App />);
let (critical, other) = Stylesheet.collect(html, css);

Taken from: https://github.com/callstack/linaria/blob/master/docs/API.md#collecthtml-string-css-string--string

The API might change, but the solution should look quite similar

@davesnx davesnx changed the title Server-side apis get all stylesheet at once Server-side apis get all stylesheet at once (maybe it should only get the "current") Oct 22, 2024
@davesnx davesnx added the feature New feature label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
Development

No branches or pull requests

1 participant