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

Remove comments from the *built* CSS files #17035

Merged

Conversation

Snuffleupagus
Copy link
Collaborator

The old pre-processor used for CSS, and HTML, files leaves comments intact which unnecessarily contributes to the overall size of the built CSS files (note that the built JavaScript files don't include comments).
Rather than trying to "hack" comment removal into the pre-processor it seems easier to use a PostCSS plugin instead. The one potential issue is that it also affects some whitespaces, and it's not clear to me if this'll work with the various CSS-related tests that run in mozilla-central.

Please refer to https://www.npmjs.com/package/postcss-discard-comments for additional information.

@Snuffleupagus
Copy link
Collaborator Author

/botio-linux preview

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_preview from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/06b61e04ab1e9b2/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/06b61e04ab1e9b2/output.txt

Total script time: 1.50 mins

Published

@Snuffleupagus
Copy link
Collaborator Author

/botio integrationtest

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_integrationtest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.193.163.58:8877/7ec583dc73f1a55/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_integrationtest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/61e9a9b45861b15/output.txt

@marco-c
Copy link
Contributor

marco-c commented Sep 26, 2023

What is the improvement in terms of size reduction?

gulpfile.mjs Show resolved Hide resolved
@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/61e9a9b45861b15/output.txt

Total script time: 5.44 mins

  • Integration Tests: Passed

@Snuffleupagus
Copy link
Collaborator Author

What is the improvement in terms of size reduction?

Comparing master against this patch for gulp mozcentral the built CSS files are ~7 percent smaller:

  • viewer.css: 77 051 bytes -> 71 795 bytes.
  • viewer-geckoview.css: 25 936 bytes -> 24 108 bytes.

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/7ec583dc73f1a55/output.txt

Total script time: 17.91 mins

  • Integration Tests: FAILED

The old pre-processor used for CSS, and HTML, files leaves comments intact which unnecessarily contributes to the overall size of the *built* CSS files (note that the built JavaScript files don't include comments).
Rather than trying to "hack" comment removal into the pre-processor it seems easier to use a PostCSS plugin instead. The one potential issue is that it also affects *some* whitespaces, and it's not clear to me if this'll work with the various CSS-related tests that run in mozilla-central.

Please refer to https://www.npmjs.com/package/postcss-discard-comments for additional information.
@calixteman
Copy link
Contributor

Could you make a patch for m-c (no need to file a bug for that: moz-phab --wip --no-bug) and link it here ? I'll make a try with it.

@Snuffleupagus
Copy link
Collaborator Author

Could you make a patch for m-c (no need to file a bug for that: moz-phab --wip --no-bug) and link it here ? I'll make a try with it.

Sure, please see https://phabricator.services.mozilla.com/D189455

@calixteman
Copy link
Contributor

Could you make a patch for m-c (no need to file a bug for that: moz-phab --wip --no-bug) and link it here ? I'll make a try with it.

Sure, please see https://phabricator.services.mozilla.com/D189455

CI is green (especially stylelint):
https://treeherder.mozilla.org/jobs?repo=try&revision=8c0d535c3fc491df81215337b4c1761f9139df3c&selectedTaskRun=OGtFooqwT7mVQRDKtLt6wA.0

@Snuffleupagus
Copy link
Collaborator Author

CI is green (especially stylelint):
https://treeherder.mozilla.org/jobs?repo=try&revision=8c0d535c3fc491df81215337b4c1761f9139df3c&selectedTaskRun=OGtFooqwT7mVQRDKtLt6wA.0

Nice, thank you!

So, does that mean that this PR is good to go?

@calixteman
Copy link
Contributor

CI is green (especially stylelint):
https://treeherder.mozilla.org/jobs?repo=try&revision=8c0d535c3fc491df81215337b4c1761f9139df3c&selectedTaskRun=OGtFooqwT7mVQRDKtLt6wA.0

Nice, thank you!

So, does that mean that this PR is good to go?

Yep I just forgot to do it.

Copy link
Contributor

@calixteman calixteman left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you.

@calixteman
Copy link
Contributor

Just FYI, the --wip was useless and made the patch on phab not visible.

@Snuffleupagus Snuffleupagus merged commit 3072efa into mozilla:master Sep 28, 2023
3 checks passed
@Snuffleupagus Snuffleupagus deleted the postcss-discard-comments branch September 28, 2023 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants