So right now I have a script working when it is written directly into the relevant template. CMS-entered text changes on hover, so I am doing this, which works fine (php variables coming from ACF fields).
The javascript should be a static, compiled file. You should be able to put your javascript and your css on a cdn and it should have no idea PHP is even a thing. You could pass data to the javascript via data attributes
Basically, it’s a way to pass PHP to Javascript, so you don’t need to clutter up your HTML with a bunch of one-off scripts.
It’s relatively straight forward to use, just remember to enqueue your script BEFORE you’ve set up the wp_localize_script for it. So something like this:
Thanks a bunch kalenjohnson and austin - I will try with data attributes first, but then will circle back to use wp_localize_script, since this is happening in a number of spots on the site.