• I am trying to enqueue SCRIPTS and CSS files of CF7 only for pages where shortcode appears as to improve Page Speed rankings.
    My aproximation would be to register scripts and css previously but only ENQUEUE them from inside the shortcode function. I am using this approach in another plugin, and it works for me.

    • First I register scripts and styles with
    • wp_register_script(‘my-script’,’my_script.js’) or wp_register_style(‘my-style’, ‘my_style.css’) inside an action’wp_enqueue_scripts’.

    • Second , I am using wp_enqueue_script(‘my-script’) and wp_enqueue_style(‘my-style’) inside my shortcode and it works.

    My question is if could not be possible to update CF7 to accomplish the same?
    Thanks in advance.

    • This topic was modified 5 years, 7 months ago by capbussat.
    • This topic was modified 5 years, 7 months ago by capbussat.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Enqueue scripts and CSS files only in pages that include shortcode’ is closed to new replies.