Never Again (External JavaScript in the Body)
This is probably simply a personal taste, but I hate putting External JavaScript tags in the body of a web page. It feels and looks very unsightly to me. But as I learn more and more JavaScript, and really start to get a feel for the small language, I’ve realized that I don’t have to. That it’d be just as easy to place them directly into the header after the page is ready, by manipulating the DOM. Here is an excerpt from the beta turled website.
$(document).ready(function() { // Google Analytics var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); var script = document.createElement("script"); script.src = gaJsHost + "google-analytics.com/ga.js"; script.type = "text/javascript"; document.getElementsByTagName("head")[0].appendChild(script); try { var pageTracker = _gat._getTracker("CENSORED"); pageTracker._trackPageview(); } catch(err) { /* Do Nothing. */ } // Facebook Share var script = document.createElement("script"); script.src = "http://static.ak.fbcdn.net/connect.php/js/FB.Share"; script.type = "text/javascript"; document.getElementsByTagName("head")[0].appendChild(script); });
As you can see, I wait until the document is loaded using jQuery’s ready method, and then create elements for both Google Analytics and Facebook Share, before appending them directly to the <head> of the website. Keeping the code clean, reducing bandwidth usage for non-JavaScript users, and even making Google’s code cleaner. (By changing Google Analytic’s default code from document.write to DOM Manipulation.
So, Never again will I feel the need to insert external script tags at the bottom of the <body> just so that the rest of the page loads before them.
Note: If you’re not using jQuery, document.onload = function() { /* Code */ } works just as well, I promise.
Depressing Validation Results
On a whim, I decided to attempt validating every website I mentioned yesterday. Overall, XHTML won out the results. But they are depressing none the less.
- XHTML
- Blogger (This Blog)
- XHTML 1.0 Transitional
- FAILED
- 70 Errors
- Opera
- XHTML 1.0 Strict
- PASS!
- FireFox (Mozilla)
- XHTML 1.0 Strict
- PASS!
- Facebook (Home Page for signed in user)
- XHTML 1.0 Strict
- FAILED
- 659 Errors (wow.)
- MySpace (Home Page)
- NO DOCTYPE FOUND (FAILED)
- Twitter (Home page for signed in user)
- XHTML 1.0 Strict
- FAILED
- 82 Errors
- W3C (Home Page)
- XHTML 1.0 Strict
- PASS!
- HTML
- Microsoft (Home page)
- HTML 4.0 Transitional
- FAILED
- 31 Errors
- Yahoo!
- HTML 4.01 Strict
- FAILED
- 294 Errors
- Apple
- HTML 4.01 Transitional
- FAILED
- 4 Errors
- Google (non-iGoogle homepage)
- NO DOCTYPE FOUND (FAILED)
- WHATWG (Homepage)
- HTML 4.01 Strict
- FAILED
- 5 Errors
PASS/FAIL Results:
- XHTML
- 3/7 Passed
- HTML
- 0/5 Passed
The Results are bad enough as they are for the XHTML websites, but not a single HTML website validates, not even the WHATWG. Irony much?
Why HTML should become a dead language
Go ahead, take a gander around the Internet. Lets see who is using HTML, and who is using XHTML.
- XHTML
- Blogger [Served as HTML]
- Opera [Served as XML]
- FireFox (Mozilla) [Served as HTML]
- Facebook [Served as HTML]
- MySpace [Served as HTML]
- Twitter [Served as HTML]
- W3C [Served as HTML]
- HTML
- Microsoft
- Yahoo!
- Apple
- WHATWG
As you can see, the "newer" websites are serving in XHTML. A few of them Transitional (mainly websites where users can input HTML), however, a large number of them are marked as XHTML 1.0 Strict using the W3C DTD.
On to my main point, HTML should NOT receive an update. The primary reason people want it to, is because it is FAMILIAR to designers and developers. However, HTML is very lax on how it is interpreted, a little too lax in my personal opinion.
An Example. <input type="text" disabled>. The tag does not end. Its interpreted as a single tag, and disabled means that its disabled. I, myself, find this to be horrible, horrible code. In XHTML, all tags must end, and all properties must have a value. Which is easier to program, an HTML or an XHTML parser?
Probably the XHTML. HTML was not designed to be parsed, and is really quite a pain to attempt to parse using such things like Regex, considering how lax of a language it is.
In my own personal opinion, HTML should become a dead language. Some people hold on to it, let them. Let them continue making their websites in Archaic HTML 4. But do we really need to run an update to it? No. We should, move to XHTML. XML has already proven to be a very dependable language. Its used in such popular applications like Jabber, and Twitter, and is used commonly with AJAX, which is the height of the "Web 2.0" Revolution.
So why are we trying to revise it? Why can't we adopt a stricter set of rules so that they can better be implemented? In my personal opinion, work on HTML should be halted, and moved to XHTML. I still believe that the W3C and WHATWG should work together on a new version of XHTML. XMLEvents and XForms should adopt the magnificent features that Web Forms 2.0 has created. Again, this is my personal opinion.
EDIT: Added What Some sites are served as. Its actually pretty depressing.
XHTML2 vs. HTML5
What the hell is up with this fanboy war? The web design community has already started getting used to XHTML, but now the WHATWG group wants the continued update of HTML? Isn't that a step backwards?
HTML was wild, unordered, and controlled by the browser vendors (at least from what I've seen), however, XHTML was started and controlled by the W3C group, making sure that it gets properly implemented, however, the WHATWG group doesn't like it. They want to stay with their old fashioned <b> tags.
I admit, web designers from the 90s have gotten used to the old style HTML tags, and its still what they're teaching in school, but that is no reason to stay with it. Technology changes over time, this is the same for any tech profession, the data will change, and then you'll have to learn something new. This isn't just the case for tech jobs, but jobs that use computers. Microsoft publishes a new Operating System, your company updates, and you need to re-learn it.
XHTML1 supports backwards compatibility with HTML for the old authors who are still getting used to it, and so that browsers can still render old code, XHTML2 doesn't, but all browsers should properly implement both. But by creating HTML5 and "XHTML5", WHATWG is requiring browser vendors to include yet another set of standards into browsers in order to properly display the internet.
Personally, I have yet to find a website that uses HTML5. Most websites have already started using XHTML, and so I truly believe that implementing a new version of HTML is a step backwards.
If the WHATWG group wants to continue their efforts (like their wonderful work with Web Forms 2.0), I think their best bet would be to join the W3C's work with CSS and XML Events, and XForms, don't you? If the two worked together, instead of fighting about such silly things, then maybe standards could be developed a lot faster, after all, the W3C does seem to be taking a long time to update and recommend standards. Lets get things done faster, I want to start using XHTML2 and CSS3 already :-p
First Post
This is the first post for my new technical blog. What will go here? Well, probably stuff like XHTML, CSS, HTML, Dave Winer, Twitter, and other random useless things that have something to do with the internet.
I'm not really sure how to start off this blog but by breaking the third wall and recognizing its a blog.. or does that only work in Cartoons and Movies? Either way, Third wall broken, Hello Audience :3
I guess that is all for now, I'll write some more later.


