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

Document how you're supposed to use minimalcss #93

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

Document how you're supposed to use minimalcss #93

peterbe opened this issue Jan 23, 2018 · 4 comments

Comments

@peterbe
Copy link
Owner

peterbe commented Jan 23, 2018

Generally the idea is that you replace your bloated external style sheets with one block of minimal CSS. That can either be injected as a new external .css or inlined. But it's generally a good idea to do something like this:

Before:

<link rel="stylesheet" href="bloatedframework.css">

After:

<link rel="stylesheet" href="builds/minimal.css">
<link rel="preload" href="bloatedframework.css" as="style" onload="this.rel='stylesheet'">

The reason why it's a good idea to still lazy load in that bloatedframework.css is because minimalcss can only figure out the minimal CSS on first page load (including XHR) before the user starts interacting and using the pointer to cause the DOM to change.

All of that needs to be explained! Ideally quite early in the README to grab peoples attention.

Also, it should probably link to loadCSS which has a good polyfill solution to lazy loading CSS. The code example above doesn't work in all browsers.

@peterbe
Copy link
Owner Author

peterbe commented Jan 23, 2018

Bonus points if we can have some gh-pages examples that demonstrate this with URLs you can throw into webpagetest.

@stereobooster
Copy link
Collaborator

stereobooster commented Jan 23, 2018

Do not forget

<noscript>
  <link rel="stylesheet" href="bloatedframework.css">
</noscript>

@peterbe
Copy link
Owner Author

peterbe commented Jan 23, 2018

Yep, I think that's part of the loadCSS solution. It's what I use on https://songsear.ch

@stereobooster
Copy link
Collaborator

stereobooster commented Jan 23, 2018

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

3 participants
@peterbe @stereobooster and others