Skip to content

Conversation

@duncanmcclean
Copy link
Member

@duncanmcclean duncanmcclean commented Jan 5, 2026

This pull request aims to improve the performance of Bard & Replicator fields during page load by reducing the payload we generate and send to the client.

Solution

Currently, when we preprocess Bard & Replicator fields, we return new and defaults arrays, which carry the default values and metadata for new sets.

By nature, we only ever need these values when you add a new set. If all you're doing is editing an existing entry, we're generating a bunch of data you don't actually need.

My "solution" is simple:

  • Stop returning new and defaults from the fieldtype's metadata
  • Perform an AJAX request when you add a set to load it's default values and metadata
    • The values/meta will be cached in a Vue property in case you want to add the same set again, avoiding unnecessary requests.

Benchmarks

I've tested this approach on a real site we've been given access to via support. I've measured the page load of the publish form page.

Before: 3.71s (1235kB)
After: 542ms (121kB)


Related: #11993

@duncanmcclean duncanmcclean changed the title [6.x] Only preProcess [6.x] Improve initial page load performance for Bard & Replicators Jan 5, 2026
@duncanmcclean duncanmcclean changed the title [6.x] Improve initial page load performance for Bard & Replicators [6.x] Improve Bard/Replicator performance during page load Jan 5, 2026
items: $replicatorSet['fields'],
parent: Data::find($request->reference),
parentField: $field,
parentIndex: -1
Copy link
Member Author

@duncanmcclean duncanmcclean Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing -1 here might be a little confusing, but according to this PR, it's the intended value when generating the new/defaults arrays.

@duncanmcclean duncanmcclean marked this pull request as ready for review January 6, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants