Loading JS/CSS just if needed
-
I’ve read your post to loading JS and CSS only when its needed: https://contactform7.com/loading-javascript-and-stylesheet-only-when-it-is-necessary/
Why don’t you load JS/CSS just when the contact-form-7 shortcode is in a post?
I’ve quickly tested in my testing environment: function wpcf7_do_enqueue_scripts() -> do not load of scripts and styles.
function wpcf7_contact_form_tag_func() -> loading wpcf7_enqueue_scripts() and wpcf7_enqueue_styles() just before return contact_form.
Thus the JS and CSS just are loaded when the shortcode in post/page is present.I don’t really sure that this was the right function to load, but I hope you understand my proposal.
I have found this tip of loading in shortcode-handler here: https://scribu.net/wordpress/optimal-script-loading.html
- The topic ‘Loading JS/CSS just if needed’ is closed to new replies.