Outline
● The traditional request-response architecture
● Incorporating AJAX to build interactive websites
● Applying the “HTML over the wire” pattern using HTMX
● Demo
Typical Progression
1. Add JavaScript to existing HTML templates
2. Pull in a component library for rendering (e.g. React)
3. Hand over routing control to the frontend
4. Rewrite all HTML views as JSON APIs (i.e. Django REST
Framework viewsets)
5. Completely extract the frontend from the backend
Ideal Use Cases
● Rich, dynamic websites
● Large teams that hire specialists
● Multiple, independently-deployable frontends
● Products with a mobile or embedded component
Slide 19
Slide 19 text
Disadvantages
● Multiple technology stacks (2+ MVCs)
● State managed on the frontend and the backend
● Potentially duplicated business logic
● Backend often viewed as “second-class” to the frontend
● Prototyping depends on establishing a data contract
Slide 20
Slide 20 text
Hybrid Applications (HTMX)
Slide 21
Slide 21 text
“HTMX allows you to access AJAX,
CSS Transitions, WebSockets and
Server Sent Events directly in HTML,
using attributes, so you can build
modern user interfaces with the
simplicity and power of hypertext.”
https://htmx.org
Models Views Templates
Partial
Partial
Partial
Partial
HTML
HTML
Slide 30
Slide 30 text
Advantages
● All logic stays in Python!
● Backend is solely responsible for stage management
● Faster prototyping using existing HTML templates
● Simplified testing of partial response endpoints