Macro HTML

0 views
Skip to first unread message

Sayu

unread,
Dec 7, 2009, 8:24:15 PM12/7/09
to Make the Web Faster
I posted on this far earlier, but as I've found to be the case often
enough when I write, nobody bit. Maybe I wasn't eloquent enough,
maybe I just didn't say anything useful. I don't really care. I want
to say it again.

HTML should, nay NEEDS to be made into a language with client-side
macros. It doesn't have to be much, and frankly all the pieces are
already there in XML and HTML-style markup. In a webpage I've been
piecing together by hand using PHP and such, I have a large form-bound
table with a lot of lines that look exactly like this:

<td class='B_r'>Body <input type='hidden' id='Body' value='1'><img
OnMouseOver='SETEV("Body",2);' src='./nud.gif' usemap='#nud'></td><td
class='BR_c'><span class='cBody' name='D_Body'>-&diams;</span></td>

All of which were generated by the same line of PHP code and which
frankly could all be expressed as a macro to the client side if there
was a markup language which supported macros. If it could be written
as easily as

<dot-editor name="Body" default="1" maxval="2" text="-&diams;">
or
<dot-editor name="Body" default="1" maxval="2">-&diams;</dot-editor>

it would save 140 characters per line, in addition to vastly improving
readability. This would require a macro definition elsewhere in the
file, increasing rendering time and minimizing or eliminating the
space benefit if you only use the macro a time or two, but...

In the end, if we REQUIRE the net to keep up with our increasing
performance demands, we WILL continue to be disappointed--if not
always, certainly often enough. Even if these macros are poorly
implemented and never standardized, but are instead all custom-created
by the code writer or compiler, even then, when if a page saves a
measly little kb on a single fetch, multiplied by a million fetches a
day, that's still gigabytes less bandwidth consumed. I'm sure there
are others better suited than me to I to comment on its possible
applications in client-side scripting and DOM, but if done properly,
it's a cheap way to losslessly compress HTML output.

And that's without it being a particularly POWERFUL macro language;
there are certainly ways to make it more interesting. I would love to
see at least an attempt at this.

itpastorn

unread,
Dec 9, 2009, 11:15:12 AM12/9/09
to Make the Web Faster
On Dec 8, 2:24 am, Sayu <supers...@gmail.com> wrote:
> <td class='B_r'>Body <input type='hidden' id='Body' value='1'><img
> OnMouseOver='SETEV("Body",2);' src='./nud.gif' usemap='#nud'></td><td
> class='BR_c'><span class='cBody' name='D_Body'>-&diams;</span></td>

Form templates were part of Web Forms 2.0 that formed the basis of
forms in HTML5, but have been dropped.

It was not that easy to add such functionality.

But a big part of why your code is messy and hard to read is that is,
frankly, is badly authored. You seem to:

1. Use tables for layout.
2. Have inline, obtrusive, JavaScript.
3. Use redundant spans.
4. Use HTML-entities instead of Unicode characters (is the page not in
UTF-8 this is probably your only option, though).

Perhaps you want that diamond shape since it is a bullet point. In
that case you should mark it up as a list in HTML and set the symbol
in CSS.

I do not know why you are using an imagemap either, but probably that
solution could be altered. Right now it is totally inaccessible, i.e.
invisble to screen readers and not focusable without a mouse.

Sorry if this sounds rough, but in order for your suggestion to carry
any weight, we need to see that you understand HTML first. Your
example is not an example of best practice. In fact it is the opposite.

T73 Net

unread,
Dec 9, 2009, 12:08:33 PM12/9/09
to Make the Web Faster
I totally agree with this. As far as macros in scripting, using a
lightweight js framework might help in that. Granted, it's not a
standardized solution, but it would be difficult at best to
standardize a solution that is meant to be custom in almost every
scenario. Consider the following using jQuery.

------------------------

<div class="elementWrap"></div>

var formElement = '<input class="formElement" value="" />';

$('elementWrap').appendTo(formElement);

------------------------
In essence what I'm saying, is write your own macros.
The possiblities are limitless!

Rakesh Pai

unread,
Dec 9, 2009, 5:00:30 PM12/9/09
to make-the-...@googlegroups.com
Considering that HTML is extensible, this thing is actually pretty easy to implement. Since you cannot/shouldn't have a one-size-fits-all solution, it's up to you to build a custom solution. I know I had done this back in the day with Prototype lib. And before that, with my custom JS lib (since there was nothing else in the market at that time).

Today, I've sort-of moved away from the idea, but I still like it in many common situations. All you need is some custom JS to help you along. You then have your "macro".

As an example, look at http://www.cleartrip.com/ - a site that I did all the front-end dev for - and it's markup for the date pickers and the auto-completes. All done declaratively. And that's just the home page.

On Wed, Dec 9, 2009 at 5:08 PM, T73 Net <ron.g....@gmail.com> wrote:
I totally agree with this. As far as macros in scripting, usingativ a
--

You received this message because you are subscribed to the Google Groups "Make the Web Faster" group.
To post to this group, send email to make-the-...@googlegroups.com.
To unsubscribe from this group, send email to make-the-web-fa...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/make-the-web-faster?hl=en.





--
Rakesh Pai
Mumbai, India.
http://piecesofrakesh.blogspot.com/
http://twitter.com/rakesh314
http://www.google.com/profiles/rakeshpai

Michael McGlothlin

unread,
Dec 9, 2009, 9:47:04 PM12/9/09
to make-the-...@googlegroups.com
I doubt it'd speed things up much to use macros if you already use
compression. Compressing the HTML should basically remove duplicate
data.

Thanks,
Michael McGlothlin
Reply all
Reply to author
Forward
0 new messages