kasparsd / contact-form-7-extras

Simple controls for the advanced Contact Form 7 features
https://formcontrols.com
18 stars 4 forks source link

Add option to load CF7 JS only on pages that contain CF7 contact form #28

Open buzztone opened 5 years ago

buzztone commented 5 years ago

This scripts.js optimization question in the CF7 Forum raises an interesting idea.

Can you please add option to load it ONLY on pages that ACTUALLY contain CF7 contact form(s)? Even if we manually have to enter/define pages by names/slugs, it will be fine with me.

It may not be technically feasible, but adding manually a list of pages with CF7 forms would probably not be burdensome for most CF7 users.

geminorum commented 5 years ago

Theoretically, It can be done simply by calling the scripts on short-code rendering (#9346), but the cf7 authors are actually, very hard to reach!

buzztone commented 5 years ago

I have regular contact with the CF7 plugin author, Takayuki Miyoshi. I've found him very approachable.

I’ve found Takayuki is open to detailed, well researched & tested code submissions, that meet what he sees as the needs of the majority of CF7 users.

geminorum commented 5 years ago

Where can I report bugs?

kasparsd commented 5 years ago

In cases when all scripts are being concatenated it is better to have all required scripts to be enqueued on all pages since then only one "bundle" script is generated and retrieved from cached on all subsequent requests.

It would be useful to have a toggle for this in the Controls plugin, though!

geminorum commented 5 years ago

On the new update of cf7, using reCAPTCHA v3, the badge will show on every single page of the site. Concatenated scripts is not optimal for specific functionality of a single form.

buzztone commented 5 years ago

Where can I report bugs?

Use form at https://contactform7.com/contact/. Be nice & you'll usually get a nice response.

buzztone commented 5 years ago

It would be useful to have a toggle for this in the Controls plugin, though!

Definitely sounds like there should be an option. There are clearly cases where either option will be a better choice.

buzztone commented 7 months ago

@kasparsd see https://github.com/rocklobster-in/contact-form-7/issues/1278#issuecomment-1716916776. Takayuki is planning to add an action hook in the shortcode callback function or somewhere else to make it easy for add-on plugins to implement the same script loading control. Takayuki is doing this to allow other plugins to add this option.