magento2-page-builder icon indicating copy to clipboard operation
magento2-page-builder copied to clipboard

[Issue] (Video) Calling jarallax-wrapper and loading on demand librairies

Open m2-assistant[bot] opened this issue 1 year ago • 1 comments

This issue is automatically created based on existing pull request: magento/magento2-page-builder#865: (Video) Calling jarallax-wrapper and loading on demand librairies


I needed to replace jarallax with jarallax-wrapper to make it work with a custom Js bundler (Magepack Bundle) Indeed, without jarallax-wrapper, window.jarallax is not populated and return an error (undefined var).

I take advantage of this commit to suggest to load on demand libraries.

Additional Details

At the time, I was using a bundler for production (https://github.com/magesuite/magepack) to manage JavaScript files. This issue is isolated to that setup.

When I compiled the files, the jarallax object was not defined, likely due to a context issue or the way the bundler handles modules (specifically, the order of the JS files).

Magento provide the jarallax-wrapper module to call the jarallax class and attach it to the window (global) object, which is why I submitted this issue in the first place to solve mine.

But the ways the requirejs-config file is declared (shim), Magento_PageBuilder/js/resource/jarallax/jarallax-video would be sufficient :

shim: {
    'Magento_PageBuilder/js/resource/jarallax/jarallax-video': {
        deps: ['jarallax-wrapper', 'vimeoWrapper']
    }
}

(it would be great to load vimeoWrapper and vimeo only on demand too)

Nowadays, with HTTP/2 and HTTP/3, bundlers are not always ideal for frontend performance which generate big JS files. It's up to you to decide whether addressing this is still relevant.

m2-assistant[bot] avatar Nov 28 '24 10:11 m2-assistant[bot]

yes ! those two scripts constantly show up in pagespeed notation because they are unused but are still initialized since Magento automatically require them before checking if any element using them are present.

afourmeaux avatar Dec 23 '24 13:12 afourmeaux

Hello @iparmentier,

Thanks for the report and collaboration!

We have tried to reproduce the issue in the latest development branch by following the below steps:

  • Install Magento 2 with the Page Builder module enabled.
  • Install and configure Magepack, a JavaScript bundler for Magento 2, in your Magento instance.
  • Compile JavaScript Files Using Magepack
  • Test the Video Functionality in Page Builder

But it is working as expected, please let us know if we missed anything here. In the meantime, we are closing this issue.

Thanks

engcom-Hotel avatar Sep 22 '25 09:09 engcom-Hotel