Giter VIP home page Giter VIP logo

htmx-mini's Introduction

htmx-mini

htmx is about 40KB minified, htmx-mini is <4KB unminified.
The project consists of a single JavaScript file, which is very easy to modify and extend.

You can read about the development of this on my website.

Documentation

This does not contain all the functionality of htmx, but, it does contain what I consider to be the most valueable part of htmx.

With htmx-mini you are able to create GET, POST, PUT, DELETE, PATCH requests. It also allows for you to add certain triggers like click, submit and whatever else may exist, together with targets that you want to replace the HTML of.

It supports the following swap modes:

  • innerHTML
  • outerHTML
  • beforebegin
  • afterbegin
  • beforeend
  • afterend
  • delete
  • none

If no trigger is defined, it uses the same defaults as htmx:

  • input, textarea and select are triggered by the change event
  • form is triggered on the submit event
  • ... everything else uses click

If a form is triggered, it includes the form data in the Ajax request.

Like htmx we expect the data returned by the server to be HTML.

Multiple triggers can be added data-hxm-trigger="load, click, customevent"

Example

<h1>Hello World!</h1>
<button data-hxm-req="get" data-hxm-url="/content">
    Get content
</button>


<p>Form</p>
<p>Type your information:</p>
<form data-hxm-req="post" data-hxm-target="p" data-hxm-swap="beforeend">
    <label>Name <input type="text" name="name" /></label>
    <input type="submit" />
</form>

showcase

Why?

Size matters.

htmx-mini's People

Stargazers

Olivier Goudron avatar rs485 avatar Benjamin Stigsen avatar

Watchers

rs485 avatar Benjamin Stigsen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.