2023-08-17 at

Webpage JavaScript Application State Should be Stored in "data-*" Attributes

It has become common in web development to write web pages which depend on a lot of JavaScript. We don't even shy away from referring to web pages as "JavaScript applications" from time to time.

Data for such applications tends to be stored in system memory by developers, but not in the DOM. Each browser window is given some working memory in which to run JavaScript, but this isn't part of the DOM.

Whereas hearkening to the original separation of concerns between JavaScript, HTML, etc., we find that if any data from a JavaScript application ends up being rendered as content to the user ... then it should really reside fundamentally in the HTML layer, which is then operated upon by JavaScript.

This is probably going to decrease performance a bit, but I'll have to test later.

No comments :

Post a Comment