Description
This issue is automatically created based on existing pull request: #27696: Initialize inline translations module only when they are enabled
Description (*)
This PR is a part of my effort to improve Magento 2 frontend performance.
The focus point of this PR was to remove downloading of inline translations JavaScript modules when they are not enabled. This was happening because they were defined in deps
, which is completely redundant because they are properly initialized in https://github.com/krzksz/magento2/blob/98e04e174906799b941011a9fb1b5890a5e7cae9/app/code/Magento/Translation/view/frontend/templates/translate_inline.phtml#L57
While I was touching the files anyway I took the liberty to:
- Move
escapeHTML
to utilities (it is not used anywhere else and there is already anunescape
counterpart). - Fixed utilities dependency for
serialize
method. - Simplify logic and variables in few places.
Performance improvement
Tested on Magento 2.4-develop with Luma and sample data.
- 207 → 203 JS requests (-1.93%).
- 794.39kB → 773.44kB JS transferred (-2.64%).
Manual testing scenarios (*)
- When inline translations are disabled there is no request for
translate-inline
JS file. - When inline translations are enabled, they work as expected.
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)
- All automated tests passed successfully (all builds are green)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status