• Resolved fokus3

    (@fokus3)


    Hello,

    how is it possible to completely disable that CF loads JS and CSS? I have implemented my own routine to load JS/CSS to minify server requests but I’m not able to disable CF (wp_dequeue_script etc. seems to be ignored). How can this be done?

    Thanks and best regards,
    Lars

    https://wordpress.org/plugins/caldera-forms/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Josh Pollock

    (@shelob9)

    Yes it is possible. When you use wp_dequeue_script() you have to use it after the script is enqueued. The earliest hook you can use to remove Caldera Forms scripts is “caldera_forms_render_form”

    Thread Starter fokus3

    (@fokus3)

    Hi Josh,

    I tried this and my code looks like this now:

    function deregister_select2_for_caldera( $items ) {
    		wp_dequeue_script( 'cfajax-baldrick' );
    		wp_dequeue_script( 'cfajax-core' );
    		wp_dequeue_script( 'cf-frontend-script-init' );
    		wp_dequeue_script( 'cf-frontend-fields' );
    	}
    	add_action( 'caldera_forms_render_form', 'deregister_select2_for_caldera', 11 );

    So far so good – the JS files will be dequeued and not loaded anymore.

    BUT – now I load these script manually inside of the footer. In the end the HTML code looks the same as when CF loads the scripts. But CF isn’t working anymore. It seems so, that the shortcode isn’t executed anymore now.

    Did I made any mistakes. How can this be solved?

    Thx for your assistance.

    Thread Starter fokus3

    (@fokus3)

    oops, found the mistake – it’s a filter and not an action. Code looks now like:

    add_filter( 'caldera_forms_render_form', 'deregister_select2_for_caldera', 11, 2 );
    	function deregister_select2_for_caldera( $items, $form ) {
    		....
    	}

    works like a charme now

    Plugin Author Josh Pollock

    (@shelob9)

    Yes, it is a filter, so you must return, $items, or it’s going to break stuff. Confusing, as you’re using it the way we normally use an action. Then again, actions, are filters…

    Thread Starter fokus3

    (@fokus3)

    Thx for your help! Support is really great 🙂

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

The topic ‘Disable Styles on JS’ is closed to new replies.