0

Magento 2.4.3 Apache Nginx MariaDB

Hello Thanks for taking the time to read this.

We have a dev site we are trying to enable Swissup Pagespeed Extension however it is getting 1 error - the merge javascript fails and different sections of the site is not working

VM26:266 Uncaught Error: Cannot find closing comment tag to match: ko template: { name: templates.loader }

We have approx 40 Third Party Extensions from one Company and it seems there is a minor syntax error somewhere in one of the extension files -

Please can anyone advise what is the best and fastest way to isolate which extension is causing the error - in chrome console it is not showing anything - atleast I can't see any exact reference to the extension

If we disable all the extension the error does not show - but disabling them one by one is not feasible because alot of dependencies within the extensions which is causing more errors.

full error is

Uncaught Error: Cannot find closing comment tag to match:  ko template: { name: templates.loader } 
at getVirtualChildren (eval at require.load (0e8c8f7bbcafffb3cb467ecd2c1bf316.min.js:178:216), <anonymous>:266:7)
at getMatchingEndComment (eval at require.load (0e8c8f7bbcafffb3cb467ecd2c1bf316.min.js:178:216), <anonymous>:267:85)
at Object.nextSibling (eval at require.load (0e8c8f7bbcafffb3cb467ecd2c1bf316.min.js:178:216), <anonymous>:282:186)
at applyBindingsToDescendantsInternal (eval at require.load (0e8c8f7bbcafffb3cb467ecd2c1bf316.min.js:178:216), <anonymous>:314:353)
at applyBindingsToNodeAndDescendantsInternal (eval at require.load (0e8c8f7bbcafffb3cb467ecd2c1bf316.min.js:178:216), <anonymous>:320:234)
at applyBindingsToDescendantsInternal (eval at require.load (0e8c8f7bbcafffb3cb467ecd2c1bf316.min.js:178:216), <anonymous>:316:90)
at applyBindingsToNodeAndDescendantsInternal (eval at require.load (0e8c8f7bbcafffb3cb467ecd2c1bf316.min.js:178:216), <anonymous>:320:234)
at applyBindingsToDescendantsInternal (eval at require.load (0e8c8f7bbcafffb3cb467ecd2c1bf316.min.js:178:216), <anonymous>:316:90)
at ko.applyBindingsToDescendants (eval at require.load (0e8c8f7bbcafffb3cb467ecd2c1bf316.min.js:178:216), <anonymous>:343:1)
at applyComponents (eval at require.load (0e8c8f7bbcafffb3cb467ecd2c1bf316.min.js:178:216), <anonymous>:3:413)e

If we use another pagespeed extension and use the Merge JS the error is not coming.

1
  • Thank You Tu Van very very helpful and knowledgeable kind
    – nem3943
    Nov 17, 2022 at 13:44

1 Answer 1

0

Debugging instructions:
The error message indicates that the template file which contains name: templates.loader caused that error.
So you can find that template file by running this command:

grep -r "name: templates.loader" app vendor

Solution: Your issue is related to some HTML elements does not have close tags, so you should make sure all HTML elements have close tags. Additionally, since Magento 2.4.4 HTML tags must be properly nested and closed.
You can take a look at a commit from Magento codebase that fixes HTML tags not properly closed to know how to implement that: https://github.com/magento/magento2/commit/5955a29bb38ba6dbcdae51fc2a6fc4f76be8ac57

I've also written a little about how to add close tags here: Magento2.4.5 Console Display HTML tags must be properly nested and closed

Reference for your issue: https://stackoverflow.com/questions/18727897/knockout-error-cannot-find-closing-comment-tag-to-match

9
  • thanks for reply i did see that post before but I am wanting to know if there any way of finding the file or even the extension which is causing this error
    – nem3943
    Nov 15, 2022 at 11:08
  • I've updated debugging instructions in my answer, please take a look.
    – Tu Van
    Nov 15, 2022 at 11:59
  • thank you again - so I add the in 2 places the code you have kindly provided in this file /public_html/lib/web/knockoutjs and where should the element show in browser debug or another file? or inside here pub/static/frontend/YourVendor/YourTheme/en_US/knockoutjs?
    – nem3943
    Nov 15, 2022 at 13:14
  • you should put these code in pub/static/frontend/YourVendor/YourTheme/en_US/knockoutjs. The link from lib file in github is for reference. Then re-deploy static content, go to frontend page and check the Console tab
    – Tu Van
    Nov 15, 2022 at 13:16
  • thank you I cant see any knockoutjs. in pub/static/frontend/YourVendor/YourTheme/en_US/knockoutjs. only knockout.min.js knockout-es5.min.js knockout-fast-foreach.min.js are there -
    – nem3943
    Nov 15, 2022 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.