How to have many Kirby blocks without ruining panel experience?

I wrote on Nolt about that, but I’m afraid I’ll need a quicker solution.

We’re refactoring our website to use blocks and have something like a site builder. Recently, we noticed that the panel got slower. After digging in, I saw that the issue was our heavy use of blocks. Our refactor is not even half-way done, so we have a lot more blocks to add, which will only make things worse.

Does anyone have an idea how to proceed? Some workaround, maybe?

what is slow exactly?

  • the panel waiting for the json from the backend
  • the panel parsing the json
  • the panel rendering the blocks while user interacts with them

[edited: see nolt. the backend parsing all yml files for those 28 blocks]

have you tried to comment out the converter?

Nope, it doesn’t help. From my tests, the biggest slowdown happens on save, at these lines of the ModelWithContent.php file:

so this is when saving. my idea was about reading the content.

have you tried to disable the validation that happens in form->isInvalid ? just for the sake of finding the bottleneck.

kirby does a lot of parsing, extracting, fixing on the yaml files to create the actual block object. maybe the core devs could add a cache to serialize and save/read that result till blueprint is modified instead of doing it all over again from the yaml file.

not sure how much one can improve validation but even here it will help if the blocks are a bit more ready (serialized cache) than just yaml.

i continued thinking about that blueprint cache and an idea came to mind…

it is possible to write all blueprint files in yaml and php. yaml will be loaded dynamically but if you use a php file it will be included in the „app“. so you get the full performance boost of like apcu cache etc.

it does not solve parsing the blueprint into field objects etc but i guess its worth a try.

it does nothing to reduce the load when parsing and rendering caused by having lots of blocks but they might load from harddisk faster.

i created a nolt idea since that might be built in as well: blueprint cache · Kirby Feedback

@hdodov Is it possible for you to share with us a simple setup that we can test?

@ahmetbora yep, I wrote in Nolt and added a reproduction repo:

2 Likes