Contact Form 7 update breaks Autoptimize JS optimization: workaround

Due to a recent major change in Contact Form 7’s frontend JavaScript Autoptimize users might have to add wp-includes/js/dist the comma-separated JS optimization exclusion list (or in some cases even wp-includes/js).

It is nice CF7 gets rid of the jQuery dependancy, but I’m not sure is replacing that with a significant amount of extra WordPress blocks JS-files was such a good idea?

Update: additionally the change also introduces nonces (random password-like strings as hidden elements in the form) which can spell serious trouble when using page caching plugins.

9 thoughts on “Contact Form 7 update breaks Autoptimize JS optimization: workaround

  1. Česlav Przywara

    Hi Frank,

    thanks a lot for sharing this information – it certainly saved me a lot of time debugging!

    Btw. I also find it cool that your latest blog posts appear on the Autoptimize settings screen – that’s how I find out about the problem when I went to check what’s wrong with my Autoptimize settings :-)

    Cheers,
    Česlav

    Reply
  2. Dr. D.

    CF7 author has always been “special” in his thoughts.

    On the other hand, we also have to thank him for his long years of free work.

    In my personal view, it of course was a mistake to jump on the fast moving train of block editor packages, but well, the whole block editor was/is a similar mistake in its current form. Still not even beta but released over a year ago, think about it.

    Reply
  3. Jim

    I’m using a very old version of the Salient theme and I only noticed an issue because every page was stuck on a loading spinner until I removed “wp-includes/js/dist/i18n.min.js” from my list of exclusions. This brought back the original console error with i18n but now brought many more. I’ve now excluded wp-includes/js/dist instead and all seems OK for now in terms of javascript errors.

    Reply
  4. Li-An

    Hello, thanks for the tip. In my case, the problem occured on one of my site in Firefox only. I noticed it because people were trying to send multiple identical messages.

    Reply
  5. Chris

    I solved the issue by excluding CF7 from the JS optomizations by adding this to the exclude list: wp-content/plugins/contact-form-7/includes/js/index.js

    Reply
  6. Zoltan

    Wow. Took me two hours resolving which plug-in gave me problems and then testing settings in Autoptimeze, until I was sent here by Google. THANK YOU for sharing this. Now (22:20 local time) I can finallly wind down.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.