javascripthtmlajaxfetch-apihtmx

HTMX AJAX dependency (vs Fetch API)


HTMX interests me because I my abilities and interests primarily lie on the backend side of the house, but I'd still like my web applications to feel interactive.

From what I've read, AJAX is slowly being phased out in favor of the JS standard, Fetch API. HTMX was originally released in 2020, so I'm curious why the developers used AJAX at all.

My questions are:

  1. For HTMX longevity, will the package eventually need to swap AJAX for Fetch?
  2. Are there elements of Ajax that go beyond what Fetch was intended for?

Sources

  1. https://developer.mozilla.org/en-US/docs/Glossary/AJAX
  2. https://htmx.org/docs/#ajax

Solution

  • From what I've read, AJAX is slowly being phased out in favor of the JS standard, Fetch API.

    No.

    That's like saying "Driving is slowly being phased out in favor of cars".

    fetch is an API for performing Ajax.

    You might be confusing Ajax for XMLHttpRequest.

    For HTMX longevity, will the package eventually need to swap AJAX for Fetch?

    Browser vendors care a great deal about backwards compatibility. Support for the APIs that HTMX depends on is highly unlikely to go away.

    Are there elements of Ajax that go beyond what Fetch was intended for?

    No.