Support

Account

Home Forums ACF PRO Remove injected scripts form front end form

Solving

Remove injected scripts form front end form

  • 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?

    <script src=”/wp-includes/js/jquery/ui/core.min.js”></script>
    <script src=”/wp-includes/js/jquery/ui/widget.min.js”></script>
    <script src=”/wp-includes/js/jquery/ui/mouse.min.js”></script>
    <script src=”/wp-includes/js/jquery/ui/sortable.min.js”></script>
    <script src=”/wp-includes/js/jquery/ui/resizable.min.js”></script>
    <script src=”/wp-content/plugins/advanced-custom-fields-pro/assets/js/acf-input.min.js”></script>
    <script src=”/wp-content/plugins/advanced-custom-fields-pro/pro/assets/js/acf-pro-input.min.js”></script>
    <script src=”/wp-content/plugins/advanced-custom-fields-pro/assets/inc/select2/4/select2.full.min.js”></script>
    <script src=”/wp-includes/js/jquery/ui/datepicker.min.js”></script>
    <script src=”/wp-content/plugins/advanced-custom-fields-pro/assets/inc/timepicker/jquery-ui-timepicker-addon.min.js”></script>
    <script src=”/wp-includes/js/jquery/ui/draggable.min.js”></script>
    <script src=”/wp-includes/js/jquery/ui/slider.min.js”></script>
    <script src=”/wp-includes/js/jquery/jquery.ui.touch-punch.js”></script>

  • If you are using an ACF field, then ACF needs those scripts to run properly. If you remove them then ACF won’t function. I’m not sure about all of them, but it is the case with most of them.

  • 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?

  • The reason why I posted this originally was because It seems unnecessary to load on the front end for example date picker and timepicker javascript files if the front end is only displaying a text input.

    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!

  • I think the same in this case,

    We should be able to remove any script if we really don’t need them, if don’t have date-picker field I don’t know why is loaded datepicker.min.js.

    This make a huge deference in page speed result pages.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Remove injected scripts form front end form’ is closed to new replies.