Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments JS not working with static caching and dynamicInclude #287

Open
@harry2909

Description

Describe the bug

We have a site hosted on Servd which makes use of static caching. They provide a dynamicInclude twig tag to omit certain parts of a template from the cache.

When including the comments templates via this dynamicInclude, both the css and JS files are not outputted, despite being selected to in the CMS.

{% dynamicInclude '_components/c-comments' %}

The comments template is basically just rendering the comments:

{{ craft.comments.render(entry.id) }}

I've overridden some templates for styling purposes. I've removed certain functionality that wasn't in use, such as the can guest comment code and notify subscribed users code. But other than that, they should be identical.

image

Due to this, I have opted to render the JS and CSS manually. The CSS does appear to work. The JS file is rendered, but doesn't seem to be actually doing anything. When I press to submit a comment, the page just refreshes without anything happening. I can't see any console errors either. The comments are not saved.

I am wondering if this has some kind of similar interaction as if it were Sprig? I am not sure if that has been looked into.

I've tried rendering the css and JS at the top of the parent template but this doesn't make a difference.

I expect that the JS would still work since its being outputted on the page. Let me know if you need any more information.

Thanks!

Steps to reproduce

  1. Include a template which renders the comments using dynamicInclude
  2. Select output css and JS in CMS settings
  3. Verify nothing is ouputted
  4. Manually output css and JS
  5. Verify css works, but JS doesn't seem to be doing anything

Craft CMS version

4.4.9

Plugin version

2.0.7

Multi-site?

No

Additional context

  • Happens on local uncached version and staging static cached environment
  • Example video:
Screen.Recording.2023年07月12日.at.13.45.20.mov

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /