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
[Vue] Chunk UMD JavaScript into a set of asynchronously loaded files #18761
Conversation
… are loaded asynchronously
👍 I guess it'll be worth it for plugins like TagManager etc where the files are only needed in specific screens. It be worth giving this a try and we can always adjust if needed 👍 @sgiehl maybe you can have a look at this? |
@tsteur note this still loads all javascript beforehand, it just does it in N simultaneous ajax requests rather than one big request. It doesn't load the files right before they are needed, that's a bit harder to do. |
got it 👍 One thing we will need to test once this is merged and a beta is out that it also works well with Matomo for WordPress and plugins. Or maybe we can also test it as part of this PR. It would require a non-core plugin though and we would need to define:
Like we have say also plugins in Some people use this to have non-core plugins with different file permissions in a different directory and Matomo for WordPress also uses it. I'm saying this as the JS files will need to be loaded from a different path as they won't be in the |
Yes, that's relevant, currently /plugins/ is hardcoded. I'll change the PR to use |
This issue is in "needs review" but there has been no activity for 7 days. ping @matomo-org/core-reviewers |
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.
Looks good to me, Test Couple plugins, works as expected, it reduce the head script
size by a lot. Worse case, use this config will reset to original disable_merged_assets = 1
. Ping @sgiehl
@diosmosis It seems the cachebuster is currently not appended to the additional js requests. Guess this part needs to be adjusted so the additional Lines 360 to 378 in 4764df9
|
@sgiehl updated |
Oh looks like tests aren't passing, not sure why disable_merged_assets is enabled for me no matter what... looking into it, no need to review right now. |
…r relative path will work
@sgiehl ok should be good for another review |
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.
Looks good to me now. We could though think about adding some tests for the new asset loading stuff.
@diosmosis can you think of any potential problem that might cause? Just wondering if we shall merge that now, before an upcoming release or better wait after it.
Sure I'll add some tests.
Can't think of any, but sure it can wait. It'll take time to add some tests anyway. |
@sgiehl added tests and fixed some issues. There's one image that needs to be updated, I'll update that before merging. Pinging in case you want to review the rest of the code first. |
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.
LGTM
Description:
cc @tsteur
Now that there are multiple plugins that have Vue code its possible to experiment with different ways of loading the JS, instead of loading everything into a single file and loading it (which might be a problem since the Vue templates get compiled). (This is the simplest/quickest approach I could think of.)
This PoC provides two different methods of loading the UMD JS files:
<script defer>
element per plugin with Vue code. Which could be a lot of AJAX requests eventually.In both they are not loaded into the main assetmanager JS files, they are instead put into separate JS files and loaded with the
defer
<script>
attribute. So they will all load asynchronously and run in the correct order after.@tsteur let me know what you think. I'm not sure if there will need to be some performance testing on cloud just to see if it's worth it.
Changes:
[General] assets_umd_load_individually
,[General] assets_umd_chunk_count
Review