magesuite / magepack

Next generation Magento 2 advanced JavaScript bundler.
Open Software License 3.0
434 stars 91 forks source link

No bundling on frontend #99

Open setrada opened 3 years ago

setrada commented 3 years ago

Hi, i have installed magepack, generating magepack.config.js and calling the "magepack bundle" after setup:static-content:deploy. Everything works fine, no errors or something else. Magento 2 extension is installed and magepack bundling on admin is on. But I cant see any improvements on frontend code... Clearing and flushing cache brings no success. Any solutions or ideas?

digiltd commented 3 years ago

What improvements are you expecting to see? The main thing that tells you it is working or not working is if there are bundle-cms.min.js bundle-common.min.js being downloaded on the homepage.

setrada commented 3 years ago

Yes. Exactly these improvements. I have over 250 js files, which are loaded in frontend. But no bundled files.

krzksz commented 3 years ago

I would start by checking how this part of code works on your environment as it is responsible for adding bundle configurations which in turn point to bundle files. Maybe the module can't see them? Maybe it thinks the option is disabled? You'll have to debug.

setrada commented 3 years ago

Sorry. I am not that code specialist. Maybe it doesnt work with M2.4.1 and PHP7.4?

digiltd commented 3 years ago

when you run magepack bundle are you seeing the bundle sizes being reported?

image

i assume you have tried in an incognito browser also?

setrada commented 3 years ago

Yes. I can see the bundle report for each template(path).

digiltd commented 3 years ago

I think you might have to start again, it does work with 2.4.1. I found this article to be helpful when getting it to work https://blog.gaiterjones.com/magento-2-javascript-bundling-with-magepack/

Though be warned, you are not going to get a score of 100, Google constantly raises the bar meaning a site might have a good score today but a crap one tomorrow. Chasing the PageSpeed "dragon" can be a massive time sink, and often something a client's seo "specialist" will claim is affecting the rankings. When we looked into this extensively, we found that competitors sites that were selling similar products and appearing on the first page, had scores lower than ours. The second result on the first page was a Magento site with a score of 3, we had ~28 but was not appearing on the first few pages.

We spent an extensive amount of time trying to get the PageSpeed score up because the client kept poking us and sending screenshots of their score. Days... weeks were spent on it, whilst at the same time their menu had a broken element in it (which we pointed out). But that wasn't important, the only thing that mattered is what a computer algorithm thought of the site. Not that fact that a page with 181 products on it was loading in 2.5s on desktop and 7s on 3g. Yet most of our mobile users were on 4g so were getting similar speeds to desktop.

Long story short, even when you get magepack to work, bundling your JS is not going to make a massive difference to your score or performance, you are still having to load all the Magento crappy JS at some point. And it will be the cause of problems you will have to debug further down the line, mixins for example, sometimes they work, sometimes they don't. It is a great tool and very much appreciated, just don't expect your hopes and dreams of having a super fast, high scoring site are going to come true once you have got it working.

A great quote is from Willem Wigman is:

"You can polish it and stick a flag in it. But this pile of JS doesn't get any prettier.