Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up[jss-ssr-vendor-prefixer] make it work on server side #279
Comments
kof
added
the
task
label
Jul 31, 2016
kof
changed the title
[jss-vendor-prefixer] make it work in SSR
[jss-vendor-prefixer] make it work with SSR
Jul 31, 2016
This comment has been minimized.
This comment has been minimized.
Maybe, as a solution - create a flag when initialize jss-vendor-prefixer that describes 2 modes:
|
This comment has been minimized.
This comment has been minimized.
A good alternative to autoprefixer, may be not as feature complete - inline-style-prefixer |
kof
changed the title
[jss-vendor-prefixer] make it work with SSR
[jss-vendor-prefixer] make it work on server side
Aug 10, 2016
This comment has been minimized.
This comment has been minimized.
As we support ie10+ we may not need all features of postcss autoprefixer so inline-style-prefixer may be a good alternative cc @rofrischmann |
This comment has been minimized.
This comment has been minimized.
(y) I will soon implement the Autoprefixer test suite (at least all relevant browser versions), but sadly I spill beer over my Macbook. It's still working, but I will wait for some days to let it dry completely. Feel free to add feature requests or bugs if the prefixer is missing something. |
This comment has been minimized.
This comment has been minimized.
We need a platform that buys open source contributors a new notebook once they loose theirs!!! |
This comment has been minimized.
This comment has been minimized.
Big companies could donate old notebooks :P But as far as I know a lot are already doing so, e.g. to open coding schools for kids, homeless people, etc. But well, it's still working, so no worries haha :D It even is quite relaxing to have some days forced not to code. I'll ping you on Gitter as soon as I am back^^ |
This comment has been minimized.
This comment has been minimized.
Are you still thinking of using |
This comment has been minimized.
This comment has been minimized.
So as i get, there are two solutions for it:
Problem with first approach: Problems with second approach: |
This comment has been minimized.
This comment has been minimized.
Best bet for server side compatibility with changing styles is to use the factory method instead of using I'm developing a quick prototype solution using |
This comment has been minimized.
This comment has been minimized.
@nathanmarks agree, I'm thinking about rewriting useSheet method from react-jss to work with react context and create JssProvider component to provide custom jss instance. @kof what are you think about it? Also I have some ideas for attaching jss sheets on server side based on https://github.com/nfl/react-helmet |
This comment has been minimized.
This comment has been minimized.
@nathanmarks have you looked into inline-style-prefixer, do you see any issues there? |
This comment has been minimized.
This comment has been minimized.
@kof the main downside is that it's a fairly large lib if you use the dynamic version. For a |
This comment has been minimized.
This comment has been minimized.
I only consider using it for server-side, where size doesn't matter that much. Dynamic version will be used on the client as it is now. |
This comment has been minimized.
This comment has been minimized.
Would be good to test both libraries against each other for the browsers to make sure output is consistent. |
This comment has been minimized.
This comment has been minimized.
Yep, it should be done at some point, because otherwise someone will wonder why ssr page is displayed differently than same page rendered on the client. There will be a need to run the same test suite, but adapted for the case that client library only adds prefix for the current runtime if at all. |
This comment has been minimized.
This comment has been minimized.
@kof If they use the dynamic version of |
kof
added
the
important
label
Nov 5, 2016
kof
added
the
plugin
label
Dec 2, 2016
kof
changed the title
[jss-vendor-prefixer] make it work on server side
[jss-ssr-vendor-prefixer] make it work on server side
Aug 20, 2017
kof
added
the
complexity:moderate
label
Aug 20, 2017
This comment has been minimized.
This comment has been minimized.
@kof seems to me like it would be cleanest if |
This comment has been minimized.
This comment has been minimized.
Using user agent string for vendor prefixing means no feature detection but agent sniffing. That is exactly what we are trying to avoid in runtime. |
This comment has been minimized.
This comment has been minimized.
@kof okay, then what about using agent sniffing on the server side and feature detection on the client side? Or are you saying that the only robust approach is to apply all prefixes on the server side? |
This comment has been minimized.
This comment has been minimized.
UA can be used during SSR, but can't if its a build time rendered CSS, so we need to find the best route. I was thinking of static prefixing for both SSR and build time for simplicity. |
oliviertassinari
referenced this issue
Jan 27, 2018
Merged
[jss] Fix the last w3c issue I'm aware of #10063
kof
removed
the
task
label
Mar 19, 2018
kof
referenced this issue
Sep 28, 2018
Closed
[question] CSS differences during SSR and hydration #301
eps1lon
referenced this issue
Jan 10, 2019
Merged
[styles] Document the CSS prefixing strategy on the server #14139
This comment has been minimized.
This comment has been minimized.
IMO a strict mode that uses |
This comment has been minimized.
This comment has been minimized.
@eps1lon that would be another interesting thing to do, but caching would be even harder. |
This comment has been minimized.
This comment has been minimized.
@kof Is this actually an issue for server-side-rendering? Isn't the hole component tree thrown away between requests anyway which reduces the usefulness of a cache? Could you specify what should be cached in jss-vendor-prefixer? Come to think of it it sounds like the simplest solution would be to advice users to pipe the output from jss into e.g. |
This comment has been minimized.
This comment has been minimized.
It might depend on consumer. If consumer can cache the responses, they will also have to include UA in that case and cache for each UA string separately, basically still possible, but will increase the size of the cache. We can allow it if it doesn't make maintaining it too complex. |
This comment has been minimized.
This comment has been minimized.
IMHO it would be great to have two modes, exactly like we had with Material-UI v0.x.
These two modes are fundamentally using a different tradeoff. I think that they both of their use cases. |
This comment has been minimized.
This comment has been minimized.
@oliviertassinari its possible. The most important thing for SSR vendor prefixing is performance, many cases won't be able to cache the final result. I don't think autoprefixer over postcss will perform well in that case. So ideally, we get something that works well without caching. If caching is possible it won't hurt. But autoprefixer without being able to cache will be probably really slow. |
This comment has been minimized.
This comment has been minimized.
It's unfortunately not as simple as writing a server side implementation of |
kof commentedJul 31, 2016
•
edited
I think the best way would be to use autoprefixer serverside. Basically a user can do it already now by passing the css generated by jss to autoprefixer, but this requires an additional build step and setup.
Lets create a separate plugin for ssr vendor prefixing to avoid unneeded dependences for people who don't need it.