Skip to content

matthiasmullie/minify - replacing JS & CSS libraries with a better one #40049

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

Open
wants to merge 8 commits into
base: 2.4-develop
Choose a base branch
from

Conversation

jakwinkler
Copy link

Description (*)

I've replaced old CSS / JS minification libraries with https://github.com/matthiasmullie/minify - which is maintained, up to date and covered with tests.

Fixed Issues (if relevant)

  1. Fixes Consider moving from tedivm/jshrink to garfix/js-minify #34309

Manual testing scenarios (*)

  1. enable CSS minification
  2. enable JS minification
  3. enable production mode
  4. test frontend, backend

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Copy link

m2-assistant bot commented Jul 8, 2025

Hi @jakwinkler. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@jakwinkler
Copy link
Author

@magento run all tests

@Den4ik
Copy link
Contributor

Den4ik commented Jul 8, 2025

@magento run all tests

@ihor-sviziev ihor-sviziev requested a review from Copilot July 9, 2025 16:17
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request replaces the legacy JShrink and CSSmin libraries with the maintained matthiasmullie/minify package for JavaScript and CSS minification.

  • JS adapter updated to use MatthiasMullie\Minify\JS
  • CSS adapter simplified to use MatthiasMullie\Minify\CSS
  • Added matthiasmullie/minify to composer.json and reordered dependencies

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
lib/internal/Magento/Framework/Code/Minifier/Adapter/Js/JShrink.php Switched import and implementation to use Minify\JS
lib/internal/Magento/Framework/Code/Minifier/Adapter/Css/CSSmin.php Removed legacy CSSmin code and used Minify\CSS
composer.json Added matthiasmullie/minify and reorganized dependencies
Comments suppressed due to low confidence (1)

lib/internal/Magento/Framework/Code/Minifier/Adapter/Css/CSSmin.php:22

  • [nitpick] Add unit tests for this new CSS minifier adapter to verify it handles various CSS inputs correctly.
    public function minify($content): string

* @throws \Exception
* @return bool|string
*/
public function minify($content)
public function minify($content): bool|string
Copy link
Preview

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

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

The return type includes bool but the implementation always returns a string. Change the signature to : string for accuracy.

Suggested change
public function minify($content): bool|string
public function minify($content): string

Copilot uses AI. Check for mistakes.

@@ -6,7 +6,7 @@

namespace Magento\Framework\Code\Minifier\Adapter\Js;

use JShrink\Minifier;
use MatthiasMullie\Minify;
Copy link
Preview

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

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

[nitpick] Import the JS-specific class directly with use MatthiasMullie\Minify\JS; and instantiate new JS() to improve clarity.

Suggested change
use MatthiasMullie\Minify;
use MatthiasMullie\Minify\JS;

Copilot uses AI. Check for mistakes.

"magento/zend-cache": "^1.16",
"magento/zend-db": "^1.16",
"magento/zend-pdf": "^1.16",
"matthiasmullie/minify": "^1.3",
Copy link
Preview

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

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

[nitpick] Dependencies in composer.json appear out of alphabetical order; consider sorting entries to improve readability.

Copilot uses AI. Check for mistakes.

@ihor-sviziev
Copy link
Contributor

@jakwinkler, please review the comments from Copilot and let us know if you would like anything to be fixed based on them. If no, I'll review the pull request

@Den4ik
Copy link
Contributor

Den4ik commented Jul 10, 2025

@magento run all tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: P3 May be fixed according to the position in the backlog. Progress: review Project: Community Picked PRs upvoted by the community
Projects
Status: Review in Progress
Development

Successfully merging this pull request may close these issues.

Consider moving from tedivm/jshrink to garfix/js-minify
4 participants