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

Script to insert the minimal CSS in your HTML #94

Open
peterbe opened this issue Jan 23, 2018 · 8 comments
Open

Script to insert the minimal CSS in your HTML #94

peterbe opened this issue Jan 23, 2018 · 8 comments

Comments

@peterbe
Copy link
Owner

peterbe commented Jan 23, 2018

First of all; minimalcss should be about generating that minimal CSS. That's the core and it's good to only have 1 core function.

I have my own hacky solutions (that work because the scope is tight) that change the HTML (e.g. build/index.html) so that it first loads the minimal CSS and then lazy loads in the CSS with JavaScript.
It would be nice to build such a script into the repo so it can be shared and improved on collectively.

Another option is to build this script into a separate repo and separate npmjs.com package.

@stereobooster
Copy link
Collaborator

Psst... I know one tool

@peterbe
Copy link
Owner Author

peterbe commented Jan 23, 2018

We should definitely do a better job of explaining, in the README about how react-snap uses minimalcss. It probably belongs more to #93 though.

@stereobooster
Copy link
Collaborator

As soon as you publish latest version of code to npm, I will update it in react-snap and craft example with gh-pages or firebase so you can see how it works.

@JohnAllen
Copy link

Did any script to inject CSS into html get written? Would be a huge help for something I'm working on!

@peterbe
Copy link
Owner Author

peterbe commented Nov 20, 2019

@JohnAllen Nothing got added to this repo and I think that's good. It's just too many "it depends". For example, I have my own blog that uses minimalcss but the tooling that replaces the <link rel=stylesheet> tags with <style> (and lazy loading <link>) is done in Python.

If you're looking for inspiration you should definitely look at react-snap.

@JohnAllen
Copy link

Cool. I think what I need/will use is this: https://github.com/Automattic/juice. Want to extra CSS from all files (html, CSS + JS) and inline it.

@peterbe
Copy link
Owner Author

peterbe commented Nov 20, 2019

Cool. I think what I need/will use is this: https://github.com/Automattic/juice. Want to extra CSS from all files (html, CSS + JS) and inline it.

No. That's something entirely different.

What tools like react-snap does is it converts...

<link rel=stylesheet href=/bloated.css>
</head>

...into this...

<style>
...minimal CSS extracted from bloated.css...
</style>
<link rel=preload as=style href=/bloated.css>
</head>

@JohnAllen
Copy link

I get that. The other thing is what I need though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@peterbe @stereobooster @JohnAllen and others