verbb / comments

A Craft CMS plugin for managing comments directly within the CMS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JavaScript still being output even with "Output Default JS" disabled

stevecomrie opened this issue · comments

Description
Even with Output Default JS disabled, The Comment plugin is still outputting a <script> tag right after the hidden __JSCHK input, that looks like this:

<script type="text/javascript">document.getElementById("__JSCHK_60fb270d45c11").value = "60fb270d45c11";</script>

All the other JavaScript is being loaded properly else where in my template by using the craft.comments.renderJs(entry.id) function, but the above <script> tag persists and is conflicting with my page level Vue container render.

Steps to reproduce

  1. Create a comment field for an entry using: {{ craft.comments.render(entry.id) }}
  2. Disable the "Output Default JS" in the settings
  3. View the rendered page source to see the above JSCHK <script> tag still being inserted into the template

Additional info

  • Plugin version: 1.8.7
  • Craft version: 3.7.4
  • Multi-site: No

Additional context

So that's for the JS captcha check, which is slightly different to Comments' JS, used for the functionality of the form, editing, replies, voting, etc.

I'll see what I can do about separating this script tag from the comment form (at the moment, it's bundled alongside it, hence your error for inline script tags).

For now a workaround is to overwrite the _includes/form.html and disable {{ craft.comments.protect() }}.
Be careful, this disables the spam protection and recaptcha check.

Actually all spam fields are always loaded with the protect method, even if spam protection is disabled. Also the recaptcha is not verified if spam protection is disabled.

if (!Comments::$plugin->getProtect()->verifyFields() && $settings->enableSpamChecks) {

I do plan to revamp the spam protection/captchas to separate them out a bit more (similar to Formie)