Skip to content

Inline css - #15988

Merged
wjordan merged 3 commits into
stagingfrom
inline-css
Jun 21, 2017
Merged

Inline css#15988
wjordan merged 3 commits into
stagingfrom
inline-css

Conversation

@wjordan

@wjordan wjordan commented Jun 20, 2017

Copy link
Copy Markdown
Contributor

This PR adds an inline_css method to a Pegasus helper, and uses it to inline various small, externally-referenced .css files directly into the HTML response.

In many cases, there's a performance benefit to inlining render-blocking CSS directly into <style> elements within HTML response. Google PageSpeed recommends Optimizing CSS Delivery. However, in many cases we would still prefer external .css files over inline :css HAML blocks for readability purposes (and to simplify linting/syntax highlighting of the external files). This approach keeps the best of both worlds, allowing us to inline critical CSS while keeping CSS code in separate files for development, allowing minimal diff to our existing codebase.

To keep an eye on the overall size of inlined CSS in our pages, I've included a development-only warning that will produce errors when the gzip-compressed size of all inlined CSS exceeds a threshold (currently 10 kbytes).

@wjordan
wjordan merged commit 1870fc0 into staging Jun 21, 2017
@wjordan
wjordan deleted the inline-css branch June 21, 2017 21:28
@wjordan wjordan mentioned this pull request Jun 22, 2017
@wjordan

wjordan commented Jun 22, 2017

Copy link
Copy Markdown
Contributor Author

This PR ended up causing some unit-test flakiness which I'm looking into and will have a fix for soon.

wjordan added a commit that referenced this pull request Jun 22, 2017
fixes bug in #15988 causing test-flakiness.
@joshlory

Copy link
Copy Markdown
Contributor

Worth reverting while we understand the issue, vs. fixing forward?

@wjordan

wjordan commented Jun 22, 2017

Copy link
Copy Markdown
Contributor Author

already understood + fixed in #16040.

ewjordan pushed a commit that referenced this pull request Jun 29, 2017
fixes bug in #15988 causing test-flakiness.
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

Successfully merging this pull request may close these issues.

2 participants