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 12 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
Copilot

This comment was marked as outdated.

@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

@engcom-Hotel
Copy link
Contributor

@magento run all tests

Copy link
Contributor

@Den4ik Den4ik left a comment

Choose a reason for hiding this comment

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

Hi @jakwinkler
Could you please fix failed static and unit tests

@jakwinkler
Copy link
Author

@Den4ik my composer.json has an information to delete this missing library:
image

https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/40049/826624ff0c5ffbdfad9abbd39e43b10a/Statics/allure-report-ce/index.html#categories/8fb3a91ba5aaf9de24cc8a92edc82b5d

for some reason something is still loading it
is it magento/framework itself ?

@engcom-Hotel
Copy link
Contributor

Hello @jakwinkler,

Thank you for the contribution!

The related issue (#34309) has been categorized as a feature request. As per the process, we’ve reached out to the Product Owner for approval via email.

In the meantime, we’re moving this PR to On Hold status.

Thanks

@ihor-sviziev
Copy link
Contributor

@engcom-Hotel, this is more about platform health - replacing old not supported tools that currently Magento using with the ones that supported. I do agree that the selected tool has to be reviewed, but I don't think it can be treated as a feature request.

@jakwinkler
Copy link
Author

@engcom-Hotel I agree with @ihor-sviziev, this is not a feature but a require step in maintaining platform health. Tests fail on none-related part of the code to that PR...
Messages and comments like this are very discouraging...

@jakwinkler
Copy link
Author

I've updated lib/internal/Magento/Framework/composer.json file, hoping all tests will pass

@jakwinkler
Copy link
Author

@magento run all tests

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 PR replaces the existing JShrink and CSSmin libraries with the maintained matthiasmullie/minify package for JS and CSS minification in Magento.

  • Adds matthiasmullie/minify and removes tedivm/jshrink and tubalmartin/cssmin from dependencies
  • Updates JShrink and CSSmin adapter implementations to use MatthiasMullie\Minify
  • Adjusts return types and cleans up old library-specific code

Reviewed Changes

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

File Description
lib/internal/Magento/Framework/composer.json Added matthiasmullie/minify; removed tedivm/jshrink
lib/internal/Magento/Framework/Code/Minifier/Adapter/Js/JShrink.php Switched adapter to use MatthiasMullie\Minify\JS
lib/internal/Magento/Framework/Code/Minifier/Adapter/Css/CSSmin.php Switched adapter to use MatthiasMullie\Minify\CSS
composer.json Added matthiasmullie/minify; removed old CSS/JS minifiers
Comments suppressed due to low confidence (7)

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

  • Update the class docblock to reflect the use of MatthiasMullie\Minify\CSS instead of the old CSSmin library.
 * Adapter for CSSmin library

composer.json:44

  • [nitpick] Dependencies in composer.json are not consistently sorted; consider ordering them alphabetically to improve readability and future merges.
        "duosecurity/duo_api_php": "^1.1",

lib/internal/Magento/Framework/Code/Minifier/Adapter/Js/JShrink.php:15

  • [nitpick] The class name JShrink is now misleading since it no longer uses the JShrink library; consider renaming it to something like MatthiasMullieJsMinifier for clarity.
class JShrink implements AdapterInterface

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

  • [nitpick] The class name CSSmin no longer reflects the underlying library; consider renaming it to something like MatthiasMullieCssMinifier for better maintainability.
class CSSmin implements AdapterInterface

lib/internal/Magento/Framework/Code/Minifier/Adapter/Js/JShrink.php:27

  • Add or update unit tests for this adapter to verify that the new MatthiasMullie\Minify\JS integration produces equivalent output to the previous implementation.
        $minifier = new Minify\JS();

lib/internal/Magento/Framework/Code/Minifier/Adapter/Js/JShrink.php:25

  • Add a parameter type hint for $content to improve type safety (e.g., public function minify(string $content): string).
    public function minify($content): string

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

  • Add a parameter type hint for $content (e.g., public function minify(string $content): string) to align with strict typing.
    public function minify($content): string

@engcom-Hotel
Copy link
Contributor

Thank you @ihor-sviziev and @jakwinkler for your valuable feedback on this PR. I completely agree with your assessment that this is a platform health improvement rather than a feature request.

Replacing outdated and unsupported minification libraries with maintained alternatives like matthiasmullie/minify is indeed a necessary maintenance step to ensure the platform's stability, security, and performance.

I've already sent an email to the PO explaining the importance of this change for platform health and requesting approval. I've emphasized that:

  1. This addresses technical debt by replacing unmaintained dependencies
  2. Improves security posture through actively maintained code
  3. Provides better minification for modern JS/CSS

I appreciate your patience and contributions to maintaining Magento's platform health. I'll update this thread once I receive feedback from the PO.

Thank you for your continued support.

@engcom-Hotel engcom-Hotel moved this from Review in Progress to On Hold in Community Dashboard Jul 16, 2025
@Den4ik
Copy link
Contributor

Den4ik commented Jul 16, 2025

@engcom-Hotel,
I fully agree with the points raised by @ihor-sviziev and @jakwinkler.
Unfortunately, in recent years, Magento has become increasingly slow and conservative when it comes to adopting new libraries or updating deprecated ones — even when those changes are critical for platform health and long-term sustainability.
Efforts like this PR are essential to keep the ecosystem viable and reduce the burden on both maintainers and merchants. I hope we can prioritize such improvements accordingly.

@jakwinkler
Copy link
Author

@magento run all tests

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

Successfully merging this pull request may close these issues.

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