Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Editor performance issues when trying to load complex ACF groups on blocks

Aperta
#973 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, jquery, php, wordpress

Direzione di ricerca

Riproduci il caso usando il blocco theme functions.php, il gruppo di campi e il contenuto del post del gist collegato, quindi analizza le prestazioni dell’inizializzazione quando il blocco si apre nella barra laterale. Inizia con il percorso di rendering di true_false e l’inizializzazione del select basata su Select2 descritta nel report, concentrandoti sul ricalcolo ripetuto degli stili. Il lavoro è completo quando i campi blocco ACF complessi vengono inizializzati senza bloccare il browser per diversi secondi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug
ACF is blocking the browser when attempting to initialize the editor fields for ACF block with complex field group and a lot of content inside of it.

This "blocking" is only happening when trying to initialize the block's fields after the page was already loaded. Also, blocking time is way smaller on Firefox.

To Reproduce
Reproduction requires the ACF & ACF Pro plugins to be installed.

  1. Register the dummy block inside the theme's functions.php using the snippet in the gist
  2. Import the field group from the gist
  3. Create the new page and insert the content provided in the gist
  4. Once page is saved, switch the block to the "preview" mode.
  5. Reload the page, wait for the editor page to load
  6. Click on the block to open its editor in the right sidebar
  7. Field group will try to initialize, blocking the browser for several seconds (~6s on my machine).
  8. After this initial blocking, editor functions normally

Expected behavior
Block fields groups should load near-instantly without blocking the whole browser for several seconds.

Screenshots or Video
Video preview of the lag when clicking on the ACF block and loading the field group:

https://github.com/user-attachments/assets/7ae1f0e8-45b2-41f3-a45c-099ed211700b

Using Chrome DevTools, I've captured the following monstrosity of the "Long Task":

Image

Code
ACF field group, code for creating the dummy block and the content of the page required for reproduction can be found in this gist: https://gist.github.com/koloml/00a529c3ce935753c5e481b0c1898ab3

Version Information:

  • WordPress Version: 6.8.1
  • PHP Version: 8.2.27
  • ACF PRO Version: 6.5.0.1
  • Browser: Chrome 139

Additional context
I've tried to analyze the profile results. As you might have seen, the issue lies in the styles recalculation constantly being triggered while field group is rendering itself. Some fields are editing the styles, invalidating the browser internal caches related to styling. Then other fields are requesting the browser to calculate some properties which are dependent on the styling. Browser then recalculates styles and fields are invalidating the styles again.

Here are my attempts to pin-point the causes of the issues from the reproduction.

Checkbox (true_false) on render() is trying to calculate width of .acf-switch-on and .acf-switch-off. JQuery then attempts to get this width and causes browser to recalculate styles. Resulting width is added to inline styles.

Image

Selector (select) with stylized UI enabled is initializing Select2 instance. During dropdown initialization, Select2 tries to subscribe to mousewheel events. This triggers special hook which calculates the line height for the options. During the calculation, it tries to request the font size on one of the parent elements.

Image

I'm pretty sure this does not cover all blocks that cause this issue. I think, at least the fields which are based on Select2 or which are using jQuery in some way might also trigger unnecessary styling recalculations.

Lingua principale
PHP
Stelle
948
Fork
198
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AdvancedCustomFields/acf

Tutte le issue di AdvancedCustomFields/acf

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.