💻
Core Web Dev Concepts
  • Building a website of reasonable complexity
  • Setup
    • HTML, CSS and Browsers
    • Chrome DevTools
    • Local Dev Setup
  • App
    • Design
    • JavaScript
    • Code design paradigms
    • State and Props
    • JSON
    • HTML templating
    • Testing
  • Infrastructure
  • Azure web hosting
  • Web servers
  • Azure Cosmos DB
  • Concepts and Systems
  • API
  • Progressive Web Apps
  • Service Workers
  • Messaging
  • Hyperapp and pug-vdom
  • StateCharts and StateMachines
Powered by GitBook
On this page

Was this helpful?

Hyperapp and pug-vdom

PreviousMessagingNextStateCharts and StateMachines

Last updated 5 years ago

Was this helpful?

Hyperapp is a micro-framework built as a kind of functional JavaScript bridge between Elm and React. By default it uses hyperscript to generate HTML within the JS code but I created an alternative approach which allows continued use of Pug templates instead.

Like React, a core feature of Hyperapp is the virtual-DOM. Any changes in state are used to update the virtual-DOM which is compared to the real DOM in the browser. Targeted updates are applied automatically in the browser. In principle this makes for a faster user experience and an easier developer life - you can focus on code logic rather than coping directly with the DOM.

In a 'traditional' app, the state of buttons etc. is retained within the button - for example in a class or attribute which describes the click status. In order to interact with the button it is necessary to directly access the DOM entry for it, query the current state and make the change. In a virtual DOM you can store the state of the button in an array somewhere. Any change you cause to that array generates an efficient background tweak to the real DOM - your code doesn't need to understand how the DOM works at all.

GitHub - jorgebucaran/hyperapp: The tiny framework for building hypertext applications.GitHub
GitHub - johnkazer/hyperapp-pug: A wrapper for Hyperapp which enables you to use Pug templates rather than JSX or hyperscript.GitHub
GitHub - batiste/pug-vdom: PUG template to HyperScript Virtual DOMGitHub
Logo
Logo
Logo