Talk given at MelbDjango on 2018-03-15
Abstract: Intercooler (http://intercoolerjs.org/) is a Javascript library that allows you to make dynamic web pages without writing any Javascript yourself. This talk demonstrates how to use Intercooler with a Django app, including using Django forms and CSRF protection with Intercooler. It will also cover a number of apps that make using Intercooler with Django even easier.
11. Solution
Lipstick!
Intercooler.js!
HTTP requests via AJAX in response to events
Response replaces contents of element
Specified by HTTP element attributes, not Javascript
Example:
<a ic-post-to="/button_click">Click Me!</a>
4 / 21
14. Issues
Intercooler is backend-agnostic
… but Django has certain expectations
URLs end in '/' (matters for POST requests)
CSRF protection for POST requests
5 / 21
15. Issues
Intercooler is backend-agnostic
… but Django has certain expectations
URLs end in '/' (matters for POST requests)
CSRF protection for POST requests
Better example:
<a ic-get-from="/button_click/">Click Me!</a>
5 / 21
16. Issues
Intercooler is backend-agnostic
… but Django has certain expectations
URLs end in '/' (matters for POST requests)
CSRF protection for POST requests
Better example:
<a ic-get-from="/button_click/">Click Me!</a>
Or (using Django template):
<a ic-get-from="{% url 'button-click' %}">Click Me!</a>
5 / 21
22. WOW!!!!!!
I thought you promised lipstick…
Trivial example is trivial
What about…
Request inputs (form data, etc.)?
Response handling?
DOM and styling changes?
Data dependencies?
7 / 21
29. Triggering Intercooler requests
Intercooler uses the "natural" event for an element to trigger a request:
For form elements, issue the request on the submit event.
For input elements except buttons, issue the request on the change event.
For all other elements, including buttons, issue the request on the click event.
9 / 21
30. Triggering Intercooler requests
Intercooler uses the "natural" event for an element to trigger a request:
For form elements, issue the request on the submit event.
For input elements except buttons, issue the request on the change event.
For all other elements, including buttons, issue the request on the click event.
Other triggers can be specified using ic-trigger-from or ic-trigger-on.
9 / 21
31. Example: form eld validation
Validate an email address when it changes
10 / 21
39. Philosophy
It can be easy for some developers to dismiss intercooler as overly simple
and an archaic way of building web applications. This is intellectually lazy.
Intercooler is a tool for returning to the original network architecture of the
web. Using HTML as the data transport in communication with a server is
what enables HATEOAS, the core distinguishing feature of that network
architecture. Intercooler goes with the grain of the web, rather than forcing
a more traditional thick-client model onto it, thereby avoiding the
complexity and security issues that come along with that model.
Yes, intercooler is simple, but it is a deceptive simplicity, very much like the
early web.
http://intercoolerjs.org/docs.html#philosophy
18 / 21
40. On Churn
Many javascript projects are updated at a dizzying pace. Intercooler is not.
This is not because it is dead, but rather because it is (mostly) right: the
basic idea is right, and the implementation at least right enough.
This means there will not be constant activity and churn on the project, but
rather a stewardship relationship: the main goal now is to not screw it up.
The documentation will be improved, tests will be added, small new
delarative features will be added around the edges, but there will be no
massive rewrite or constant updating. This is in contrast with the software
industry in general and the front end world in particular, which has
comical levels of churn.
Intercooler is a sturdy, reliable tool for web development.
http://intercoolerjs.org/docs.html#philosophy
19 / 21