If HTML Used Convention Over Configuration …

Browsers would automatically pull in CSS and JS according to the filename and I would no longer have to look for an example every time I need a link or script tag.

In the absence of any other spec, /abc/def.html would cause the browser to look for /abc/def.css and /abc/site.css and /site.css. And then it would look for the same, but in JS – /abc/def.js, /abc/site.js, and /site.js. If I had all the time in the world, I’d make an Apache filter to do just that.

This would slow things down a little, but have you noticed – the world is becoming faster? It’s an another example of abundance thinking. Also, if it was a standard, it would not really slow things down as browsers and servers would develop protocols for speeding things up.

So I created a little Ajax web app template to put all the skeleton Ajax code on one page.

HTML

<html>
  <head>
     <title>Hello World!</title>

 &lt;script type=&quot;text/javascript&quot; src=&quot;app.js&quot;&gt;&lt;/script&gt;
 &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;app.css&quot;/&gt;

</head> <body> <h1>Hello World!</h1> <input id="search" name="search" />

</body> </html>

CSS

body { background-color: white; }
div.error { font-color: red; }

search { width: 200px; }

Javascript

function $(id) { return document.getElementById(id); }

window.onload = function() { $("search").onclick = function() { alert("The search begins!"); } }

5 thoughts on If HTML Used Convention Over Configuration …

Comments are closed.

  1. I take exception to ‘the world is getting faster’ thinking. Bandwidth is increasing, but latency is not keeping pace (http://www.edgeblog.net/2007/its-still-the-latency-stupid/). Reducing network round trips is still the best way to improve perceived performance of an application. And script tags exacerbate the issue — since they are pulled and executed serially, each of the 3 js requests would be a blocking network round trip, likely in the head of the document before the end user sees any content.

    Of course, to your point, standardization would probably lead to mitigation factors to the serial loading — perhaps all of those requests could be sent in parallel. But the latency issue isn’t going away.

  2. Ryan, this is a fair point given latency really is lagging. The potential mitigating factors would make it a non-issue, but you’re right to correct my over-generalisation. You must be some kind of performance expert :)

  3. I am not sure I completely understand your intention with this but it seems the convention approach is a leaky abstraction. Its convenient except in the case where you need multiple files or no files included. Then it becomes a real pain. In my work this convention would only work for an example page. Everything else we work on has far more complex asset requirements. We use server-side code to determine what is required and then pack and concatenate and cache it for maximum performance.

  4. Wioota, “Convention Over Configuration” still embraces flexible configuration….the bonus over “Just Configuration” is you get sensible defaults. In this case, you could still include your own Javascript and CSS files, and even veto the use of those automatic ones. It’s just that in the 95% of situations where that’s all you need, you don’t have to do any confi at all.

    The cool thing is it supports agile develoment because you can get up and running immediately and worry about performance and complexity later on and as the need arises.

    In HCI terms, it’s just the enshrined principle of choosing sensible defaults.