Remove vendors.js as a frontend dependency #750
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uses externals for dependencies, so they are shared between plugins and blocks.
Looking at the vendors.js
compiled code, I still see things like lodash
dependency. Only 1 request for lodash.js
is made, but the dependency is also shipped in vendors.
externals: [ lodash: 'lodash' ],
in the webpack config should remove it from vendors and build the blocks js to look for lodash on the window.
EDIT: on frontend.js compiled code, I do see that lodash is not included:
/***/ "lodash":
/*!**********************************!*\
!*** external {"this":"lodash"} ***!
\**********************************/
I think its an easy win with a few changes to the webpack config (I hope its easy at least), so may as well try to get it in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Nice improvement here. Do you have a before/after file size? It might be nice to include in the release notes.
👍
Basically it saves 2.57MB of |
* Load frontend scripts only when required * Typo * Use register_script from Assets * Remove vendors as a frontend dependency * Simplify webpack config
Depends on #746.
This PR:
vendors.js
as a frontend dependency.packages.js
andvendors.js
files. They were split sovendors.js
could be included in the frontend, but that is no longer necessary.How to test the changes in this Pull Request:
Test
vendors.js
is no longer a dependency:vendors.js
file was loaded.Test we are using externals
lodash.js
file was loaded.Changelog
Use externals for frontend dependencies so they are shared between extensions and blocks. That saves 2.57MB on page weight.