Vanilla JavaScript, Libraries, And The Quest For Stateful DOM Rendering<\/h1>\nFrederik Dohr<\/address>\n 2024-02-22T18:00:00+00:00
\n 2024-04-06T16:05:18+00:00
\n <\/header>\n
In his seminal piece \u201cThe Market For Lemons<\/a>\u201d, renowned web crank Alex Russell lays out the myriad failings of our industry, focusing on the disastrous consequences for end users. This indignation is entirely appropriate according to the bylaws of our medium<\/a>.<\/p>\nFrameworks factor highly in that equation, yet there can also be good reasons for front-end developers to choose a framework, or library<\/a> for that matter: Dynamically updating web interfaces can be tricky in non-obvious ways. Let\u2019s investigate by starting from the beginning and going back to the first principles.<\/p>\nMarkup Categories<\/h2>\n
Everything on the web starts with markup, i.e. HTML. Markup structures can roughly be divided into three categories:<\/p>\n
\n- Static parts that always remain the same.<\/li>\n
- Variable parts that are defined once upon instantiation.<\/li>\n
- Variable parts that are updated dynamically at runtime.<\/li>\n<\/ol>\n
For example, an article\u2019s header might look like this:<\/p>\n
<header>\n <h1>\u00abHello World\u00bb<\/h1>\n <small>\u00ab123\u00bb backlinks<\/small>\n<\/header>\n<\/code><\/pre>\nVariable parts are wrapped in \u00abguillemets\u00bb here: \u201cHello World\u201d is the respective title, which only changes between articles. The backlinks counter, however, might be continuously updated via client-side scripting; we\u2019re ready to go viral in the blogosphere. Everything else remains identical across all our articles.<\/p>\n
The article you\u2019re reading now subsequently focuses on the third category: Content that needs to be updated at runtime.<\/p>\n
Color Browser<\/h2>\n
Imagine we\u2019re building a simple color browser: A little widget to explore a pre-defined set of named colors<\/a>, presented as a list that pairs a color swatch with the corresponding color value. Users should be able to search colors names and toggle between hexadecimal color codes and Red, Blue, and Green (RGB) triplets. We can create an inert skeleton<\/a> with just a little bit of HTML and CSS:<\/p>\n
\n 2024-04-06T16:05:18+00:00
\n <\/header>\n
Frameworks factor highly in that equation, yet there can also be good reasons for front-end developers to choose a framework, or library<\/a> for that matter: Dynamically updating web interfaces can be tricky in non-obvious ways. Let\u2019s investigate by starting from the beginning and going back to the first principles.<\/p>\n Everything on the web starts with markup, i.e. HTML. Markup structures can roughly be divided into three categories:<\/p>\n For example, an article\u2019s header might look like this:<\/p>\n Variable parts are wrapped in \u00abguillemets\u00bb here: \u201cHello World\u201d is the respective title, which only changes between articles. The backlinks counter, however, might be continuously updated via client-side scripting; we\u2019re ready to go viral in the blogosphere. Everything else remains identical across all our articles.<\/p>\n The article you\u2019re reading now subsequently focuses on the third category: Content that needs to be updated at runtime.<\/p>\n Imagine we\u2019re building a simple color browser: A little widget to explore a pre-defined set of named colors<\/a>, presented as a list that pairs a color swatch with the corresponding color value. Users should be able to search colors names and toggle between hexadecimal color codes and Red, Blue, and Green (RGB) triplets. We can create an inert skeleton<\/a> with just a little bit of HTML and CSS:<\/p>\nMarkup Categories<\/h2>\n
\n
<header>\n <h1>\u00abHello World\u00bb<\/h1>\n <small>\u00ab123\u00bb backlinks<\/small>\n<\/header>\n<\/code><\/pre>\n
Color Browser<\/h2>\n