
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
**Version 2.0.0 of Magepack released, with greater performance results and easier usage!**
Version 2.0.0 of Magepack released, with greater performance results and easier usage!
Magepack is a bold attempt in making Magento 2 frontend as fast as never before. It builds on experiences gained with Advanced JavaScript bundling guide and Baler to provide the best of both worlds - ease of use and superior performance.
* All data gathered on clean Magento 2 with sample data installed.
Here are the requirements for Magepack to work:
mixins.js
module patched (patch provided and explained here).jquery.cookie
module shim (patch provided and explained here).Install with npm:
npm install -g magepack
Install with yarn:
yarn global add magepack
Usage: magepack [generate|bundle] <options...>
Options:
-v, --version Output the current version.
-h, --help Show this command summary.
Commands:
generate [options] Generate optimization configuration based on given page URLs.
bundle [options] Bundle JavaScript files using given configuration file.
First step is to run the generation against the existing, working shop. You can do it on any machine with access to the target shop, even your own computer. The goal here is to collect all of the RequireJS dependencies needed for a certain type of page layout. Currently, following bundles are prepared:
cms
containing modules needed by CMS pages.category
containing modules needed by category pages.product
containing modules needed by product pages.checkout
containing modules needed by cart and checkout pages.In addition, there is the common
bundle created by extracting all modules needed by each of above and loaded on every page.
magepack generate --cms-url="{{CMS_PAGE_URL}}" --category-url="{{CATEGORY_PAGE_URL}}" --product-url="{{PRODUCT_PAGE_URL}}"
There are 3 required options you need to pass:
--cms-url
- URL to one of CMS pages (e.g. homepage).
--category-url
- URL to one of category pages.
--product-url
- URL to one of product pages.
Note: By default, Magepack will use given product page, add this product to the cart and visit both cart and checkout pages to collect dependencies. To avoid this, use the --skip-checkout
option.
Running the above command will generate magepack.config.js
file, where you can find each of the prepared bundles with the list of modules that will be included in them.
Once you have generated bundler configuration, the next step would be to trigger the actual optimization after static content deploy stage has finished by running the following in shop root directory:
magepack bundle
This command will iterate over each deployed locale (excluding Magento/blank) and prepare bundles for each of them.
There are multiple optional params you can set:
-c, --config
- defining the configuration file path, in case you have multiple configuration files (e.g multiple themes with individual configuration files)
-g, --glob
- defining where to look for locales to bundle.
-s, --sourcemap
- enables sourcemap generation for bundled js.
-m, --minify
- overrides Magento 2 JS minification setting, minifying the bundle using Terser (used by default if Magento 2 JS minification is enabled).
It is possible to enable sourcemaps for bundled JS files, using the -s, --sourcemap
flag with magepack bundle
command. However, there are couple of caveats:
-m, --minify
flag exists to minify the resulting bundle using Terser.Once you made sure Magepack Magento module is installed, what is left is to enable it via admin panel under Stores->Configuration->Advanced->Developer or CLI:
bin/magento config:set dev/js/enable_magepack_js_bundling 1
and clearing the cache:
bin/magento cache:clean
Now the shop should be way faster then before 🚀 You can (and should) even enable all Magento's performance optimizations (except JavaScript bundling of course) for even better results.
Here are our tests results, testing homepage on local development environment with clean Magento 2.3.4, sample data, all caches enabled and following optimizations:
Merge JavaScript Files
- Yes
.Enable JavaScript Bundling
- No
.Minify JavaScript Files
- Yes
.Move JS code to the bottom of the page
- Yes
.Merge CSS Files
- Yes
.Minify CSS Files
- Yes
.Use CSS critical path
- Yes
.Minify Html
- Yes
.Please note that Baler does not currently support Magento's JavaScript merging and minification.
Before rising an issue please follow below guidelines:
--debug
or -d
flag that makes Magepack output more information about the ongoing process which should make debugging easier.We use SemVer for versioning. For the versions available, see the tags on this repository.
This project is licensed under the OSL-3.0 license - see the LICENSE.md file for details
FAQs
**Version 2.0.0 of Magepack released, with greater performance results and easier usage!**
We found that magepack demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.