Search code examples
htmx

Uncaught TypeError: htmx.defineExtension is not a function


When using HTMX in the console, you see the error

Uncaught TypeError: htmx.defineExtension is not a function

Using HTMX debug does not present any additional information.


Solution

  • First make sure you are loading the response-targets.js Extension of HTMX.

    If it is still a problem, there is a good chance that you have chosen an html ID that breaks HTMX. example:

    <div id="htmx"></div>
    

    This confuses htmx and leaves it unable to to know the difference between its javascript, which starts htmx. and the ID of the html which is also htmx.

    to resolve change this id so it is not htmx

    <div id="new-htmx-id"></div>