Live data from Hacker News

Substituting JavaScript with HTML

codementor.io

1–10 of 42 posts

Re: Substituting JavaScript with HTML

#2
Wait what.. ends with: "So now the JS library listens on the special classes and acts accordingly. This as opposed to what we had earlier is that now for N number of times we work with data from the backend the JS code responsible for it is the same. So for instance if you compare JQuery to Bootstrap. whereas you write some amount of JS to use J [cut-off]".

Surely this is just re-factored JS then?!

Re: Substituting JavaScript with HTML

#4
Clickbaity title due to not making clear that it is purely about the interface to the library.

Lea Verou called an interface like this "HTML API", which standing alone also is missing the script context but is at least clear in that it is about the API, not the entire code: https://www.smashingmagazine.com/2017/02/designing-html-apis...

List of examples http://markapp.io/

Re: Substituting JavaScript with HTML

#6
Hm, this sounds suspiciously what AngularJS (and I assume other projects too) did as early as 2011 - apply the Javascript logic via template / attributes instead of fetching elements via Javascript and applying logic.

Re: Substituting JavaScript with HTML

#7
It seems as if the author is on the way to rediscovering the idea of Unobtrusive JavaScript, aka the RSJS pattern (Reasonable System for JavaScript):

http://ricostacruz.com/rsjs/

The main difference is that Unobtrusive JavaScript relies on HTML5 data attributes rather than misusing CSS classes.

Perhaps the most well-known example of the Unobtrusive JavaScript approach are the AJAX helpers of Rails:

http://guides.rubyonrails.org/working_with_javascript_in_rai...

Re: Substituting JavaScript with HTML

#9
It's nice that forms work without JavaScript. Maybe we should make more stuff work without JavaScript too !? Maybe an option to bind HTML to program state, automatically updating the element's values when the state changes for example from a web socket message, or user click, but without the help from JavaScript.
Post reply on HN