QwikDev / partytown

Relocate resource intensive third-party scripts off of the main thread and into a web worker. 🎉
https://partytown.builder.io
MIT License
13.08k stars 438 forks source link

[✨] Magento 2 integration #527

Open rostilos opened 10 months ago

rostilos commented 10 months ago

Is your feature request related to a problem?

Magento 2 integration request

Describe the solution you'd like

Hi! I work in a company that develops projects on magento 2, and not so long ago I discovered partytown library that I would like to use during optimisation on some projects. Unfortunately I didn't find official partytown support for magento 2, so I wrote a small support module ( https://github.com/rostilos/perspective-partytown ) . But I would like to have an official integration among other things. Would you be interested in this?

Describe alternatives you've considered

https://github.com/rostilos/perspective-partytown

Additional context

No response

gioboa commented 10 months ago

Hi @rostilos that's great. A guide on how integrate Magento will be amazing. How can I test it? Can you describe the minimal steps please?

rostilos commented 10 months ago

For testing first of course we will have to deploy magento2 on a local machine. The following CLI utility can help with this: https://github.com/wardenenv/warden-env-magento2 https://docs.warden.dev/environments/magento2.html

Next, it will be necessary to connect gtm to the site, with ga, fb pixel, hubspot (at least something from this list) included in it.

After that you will need to start a reverse proxy ( I used cloudflare-workers for that ).

To install the module - put it in the app/code folder ( at the moment the module is not fully finalized in terms of "clean" implementation, because it was made more as a test solution, in the future it is planned to bring it to the standards of M2, to give the opportunity to install as a separate composer package ).

Then configure the settings of the module itself ( everything is intuitive there, there is an option to configure via admin panel, screenshot under the repository in git).

After that you can test it

gioboa commented 10 months ago

It sounds great. Would you like to drop a PR to describe the Magento integration steps?

rostilos commented 10 months ago

Yeah, I'll try to make time next week.

rostilos commented 10 months ago

But before that, let me be clear : do you want a complete list of steps to reproduce how this can be implemented in M2 ( including the deployment of M2 itself on the local environment ) ? I can describe it in text form, or I can record a video tutorial (whichever is more convenient).

But in that case, I'd like to refine the module first to meet certain standards. Because at the moment, although it provides an opportunity to use all the functionality, it is not fully designed, and represents a minimally functional version (I believe that the solution that will be recognized as part of the official integration must meet all the requirements of the platform, in this case - magento 2).

gioboa commented 10 months ago

Yep, I think the same. We need to have the full integration before creating the docs page. You can look at the other integrations i.e. Shopify Hydrogen The M2 setup could be taken for granted.

JMLucas96 commented 8 months ago

Any updates on this?

rostilos commented 8 months ago

@JMLucas96 I'll probably look into it in the future, but at the moment I'm pretty busy with my main job. You can try to use the compatibility module from the https://github.com/rostilos/perspective-partytown