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

print minified css for global styles #24924

Merged

Conversation

aristath
Copy link
Member

Description

For development purposes adding tabs and linebreaks to the generated styles makes sense since it makes things easier to read. But for production and code that is going to be shipped to millions of websites, we should try to minimize our footprint as much as possible.
This PR modifies the generated CSS from global styles so they don't include tabs, spaces, and linebreaks.
Every byte counts.

How has this been tested?

Tested that the same styles get generated and printed, the only thing that changes is whitespace.

Types of changes

Removed whitespace characters from the gutenberg_experimental_global_styles_resolver_styles function.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@annezazu annezazu added CSS Styling Related to editor and front end styles, CSS-specific issues. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Sep 2, 2020
@oandregal
Copy link
Member

What do you think of using SCRIPT_DEBUG to decide which version (dev or prod) to output?

@aristath
Copy link
Member Author

What do you think of using SCRIPT_DEBUG to decide which version (dev or prod) to output?

Good idea, added an extra check for that.
The CSS will now be printed with whitespace when using SCRIPT_DEBUG, and minified when on production 👍

Copy link
Member

@oandregal oandregal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works nicely, thanks!

@oandregal oandregal merged commit d2bf762 into WordPress:master Sep 8, 2020
@github-actions github-actions bot added this to the Gutenberg 9.0 milestone Sep 8, 2020
@aristath aristath deleted the aristath/try/minify-global-styles branch September 8, 2020 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants