Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

KTSearch


I am experiencing a JavaScript error in my Craft project related to the KTSearch component, even though I am not actively using the search functionality. I believe this may be due to remnant or hidden code from the original template. Below are the details:

scripts.bundle.js:1 Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')
at o (scripts.bundle.js:1:36882)
at r (scripts.bundle.js:1:36810)
at new KTSearch (scripts.bundle.js:1:39876)
at Object.init (scripts.bundle.js:7:24971)
at HTMLDocument.<anonymous> (scripts.bundle.js:7:25354)

Context:
I am not using the KTSearch functionality in my application, but the search component’s HTML (e.g., <div id="kt_header_search">) may still be present in the template, possibly hidden or unused. The error suggests KTSearch is trying to initialize and access an element that is null, causing the script to fail.

Questions:

How can I safely disable or bypass the KTSearch initialization without modifying my existing codebase, given that I’m not using the search feature?
Is there a configuration or script override to prevent KTSearch from running if the component is present but unused?
Could hidden or commented-out elements (e.g., a missing <form> or <input>) in the template cause this error? If so, how can I address this without altering the HTML?
Are there known issues with KTSearch initialization in unused components, and is there a patch or update to resolve this?
Request:
Please advise on how to eliminate this error without making changes to my HTML or template structure, as I’d prefer to keep the original code intact. A simple script override, configuration change, or guidance on disabling KTSearch would be ideal. If needed, I can provide the full HTML file for further analysis.

Thank you for your assistance, and I look forward to your guidance.

Best regards,

Dustin


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (3)

Deleted comment

Upgrade your wardrobe today with cozy and fashionable women winter clothes perfect for casual and formal wear. Learn more.



Hello everyone! I was looking for a reputable casino and settled on Luxury Casino CA. I've been playing for a month now and am very satisfied. The bonuses are simply fantastic, especially for new players. There is a huge selection of slots and the graphics are excellent. I withdrew my money without any problems. This casino is definitely worth checking out!



Hi,

Sorry for the late reply.

You can remove "js/components/search.js" component from your project and the recompile your assets/js to effect this change.

Also in the HTML code remove any search related code(if any left) in the layout code.

If you need any further clarifications please do let us know.

Regards,
Sean


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(