W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2015

Re: [whatwg] HTML6 single-page apps without Javascript proposal now on Github

From: Bobby Mozumder <mozumder@futureclaw.com>
Date: Thu, 26 Mar 2015 03:37:03 -0400
Message-Id: <0B2D0847-8F35-4793-BC6E-5777475C591B@futureclaw.com>
To: Matthew Sotoudeh <matthewsot@outlook.com>
Cc: WHATWG <whatwg@whatwg.org>

> On Mar 24, 2015, at 10:57 PM, Matthew Sotoudeh <matthewsot@outlook.com> wrote:
> Hello!
> By way of introduction, I'm an author who reads some of these mailing lists but (almost) never replies.
> This proposal is quite interesting, wanted to throw in my two cents as well:
> 1. Would you consider writing a polyfill/Javascript framework for this? 
> It seems to me that the fundamentals of the proposal could be fairly 
> simply written into a small Javascript polyfill by intercepting a[mref] 
> clicks and filling up <template>s. A working polyfill would give 
> people a chance to play around with the proposal, give you (and others 
> who like the idea) a working implementation of it in case it doesn't 
> become a standard, and provide an otherwise-necessary polyfill for older
> browsers if it does become a standard.

I see the other Javascript MVC frameworks as solving the same problem.  I’m also coming in from the author side and don’t really want to make another framework, but it is something I’m considering..

> 2. You've mentioned before that this would be more useful for beginners 
> (who only know HTML, not Javascript), but I don't necessarily agree. 
> With this proposal you would need to explain how the browser downloads 
> "JSON data" from the mref attribute's location, then somehow parses into
> a model, and then fills up and displays a template (making what the 
> page is actually showing extremely different from what they write in 
> their editor, not exactly intuitive). IMO the biggest hurdle for a 
> beginner to get over would be conceptually understanding the models and 
> templates, which HTML's declarative nature seems to make more difficult 
> to understand. I would prefer having a Javascript library where the user
> could write something along the lines of "link.onclick = 
> fillTemplate(loadData())", making what's actually happening when a user 
> clicks a link much clearer. The person would still need to understand 
> some Javascript, but not much more than what's necessary for the model 
> attributes in your proposal currently.

Writing HTML templates would still be a lot easier than writing Javascript, since people start with HTML first, and understand that before going into Javascript. And besides, you have to write templates anyways with any modern framework.  

Also, people find declarative concepts easier to understand than imperative languages.  Your “link.onClick = fillTemplate(loadData())” is an imperative script that authors have to figure out from infinite possibilities available in Javascript, which is disconnected from the structure of the HTML document.  You have to duplicate the “link” reference in your Javascript, and would mostly likely have to traverse the DOM hierarchy to find that link to assign the onClick.  

How would a author even know how to select the element to assign?  Do they have to make sure to include an ID tag to help search through the hierarchy?  So many problems there..

Compare your version to: 
	<A mref=‘http://api.mysite.com/article-1' receiver=“myArticle”>
	<H1 model=“myArticle.headline”>

where the elements and properties have clearly defined & fixed roles that assign actions.  And, they operate on those elements, because they were assigned right there. There’s no duplication of hierarchy.  You don’t have to go back through the document to find the elements again, because it was assigned when you built the document in the first place.

It’s just as how:

	<A href=“www.mywebsite.com/article'>

clearly defines a link that loads a new page action.

Assigning actions via Javascript just makes the system so much more complex.

With this proposal, it falls in line with the use model of static HTML pages, with the added benefits of dynamically loaded content without learning a separate Javascript framework.  (or trying to figure out which framework to use.)

> I'm also curious as to how many beginners would *want* to do a SPA with 
> templates and models like this, I would imagine that by the time you 
> have a real need to load data from a backend API into models and 
> templates without reloading the page that you'd have a workable 
> understanding of Javascript enough to use an existing MVC framework of 
> your choice.

For APIs, the “<MODEL>” definitions could be supplied by the API vendor.  I don’t list it in my example, but the model definitions could come in from an external source.

For example:

	<MODEL src='http://api.mywebsite.com/article'>

would load in model definitions (and possibly fixtures) from an API vendor.  

The web page's author would then just pick and choose model elements to put in their website’s template.

There are 75+ million Wordpress sites and 200+ million Tumblr pages that could benefit from this scenario, at the very least.

Bobby Mozumder
FutureClaw Magazine
Received on Thursday, 26 March 2015 07:57:34 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:29 UTC