First of all, this is not a question about general Magento 2 performance. I'm already aware of how to speed up Magento 2, in general.
My question is specifically about RequireJS and the assets served via the pub/static
directory.
I've just installed a fresh copy of Magento 2.3.4. Even without any further custom additions from me, the pages load incredibly slowly. I've noticed this is due to a massive number of requests (mostly for scripts) being served via require.js
and the pub/static
URL.
There are two problems I notice:
- The scripts only load in small batches of about 10 at a time.
- Each script takes at least several seconds to load, even if I open its URL directly in a new browser tab.
These issues combined result in a massive 3-4 minute page load time.
Take a look at this network graph as I load a category page:
Here is an example of the timings for a typical JavaScript file (they are all like this):
Even accepting the fact the assets are not cached, it should not take this long to fetch and copy or symlink assets via pub/static
, in my opinion.
I have tried using both the "copy" and "symlink" strategies and both are equally as slow.
Why is this happening? How is this considered remotely acceptable? When I was learning development the "golden rule" was that caching is not an acceptable solution for terrible performance. If the application can't perform at least "reasonably" well without a cache, then something is wrong.
What is wrong here?