This is all very useful tx, maybe my idea of data attributes for the front end is not so silly after all but the idea of some inline js is also great. I was almost there with two different init scripts for front end [vanilla] and back end [jQuery], I think I now know the best approach to pursue. The approaches you provided make a lot of sense.
wp_localize_script() is very useful too – I didn’t know that function.
Thanks for your help and advice – I missed in the docs the ACF javascript API being back end only.
Thank you for your time spent responding to this.
Hi John.
Tx for your swift answer, I have always valued the knowledge you share on this forum and have learned a lot from it.
Yes – I am trying to find a way to access field data in front end and back end scripts and use it to configure a third party javascript component without using jQuery.
Do you know any clean way of doing this or a further avenue I could explore.
At the moment I am getting somewhere with writing data-attributes into generated html blocks and then accessing them with javascript but it seems a bit backwards.
It would be great if the fields were available as JSON.