I have a simple field added to the comment form on my site, however ACF injects a bunch of unnecessary scripts. How can i remove these?
Hi! Sorry to revive this old thread, but I found this searching for an option to deactivate certain fields on the frontend. Right now, I’m able to dequeue the CSS and JS manually and that’s okay for most of my fields, but I also have some fields that echo some content (namely SVG icons that are hidden with display:none) to facilitate rendering them on the backend when they’re needed.
That also comes from the fact that I have a few custom fields plugins enabled on the website I’m working on and I’d like to selectively stop them to be “activated” at all on the frontend. All of the fields are always enqueueing their settings and assets regardless if they’re used or not in the form I’m actively displaying on the frontend. In that example, my SVG Icon selector enqueues it’s CSS, JS and echoes its icons even if there’s no SVG Icon selector field added in the form itself.
Seems like there should be a filter to shortcircuit a field altogether in that case but I can’t find it right now, but that brings me to the other question: aren’t fields lazily initialized? Should they not or is it too complicated since it doesn’t really matter for the backend of things?
I think the last comment just posted might be echoing this – there is a way to conditionally include scripts on the front end based on what fields are actually being used.
Anyway, I’m not anymore concerned with this but thought I would offer my reasoning. Cheers!
The topic ‘Remove injected scripts form front end form’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!