Joomla developers, please make sure your extensions validate!

Whenever I test a new extension, one of the first things I test is validation. Using the W3C validation service I can check if the extension outputs validating code.

The Markup Validation Service is a validator by the World Wide Web Consortium (W3C) that allows Internet users to check HTML documents for conformance to HTML or XHTML standards. It also provides a quick method for web page authors to check their posted pages for mark-up errors.

Running your site through a check like this is valuable and and easy way to check if you have made any mistake in your coding.

And, as I mentioned, it is a really good way of knowing if the brand new extensions you installed in your Joomla site will produce validation errors on your page.

HTML and CSS errors may have a negative impact on your the search engine visibility of your site. It can also break your page in various browsers that have a strict implementation of the standards.

Why is this such a big problem?

When looking at a lot of modules for Joomla from the validation standpoint, it might seem like many developers just don't care about validation. That may be the case, but it could also be about lack of knowledge. Joomla and PHP have a very low barrier to entry. It's very easy to get started, and you can start coding a Joomla extension without knowing anything about web standards.

Many developers learn to code by reading code created by others. In the case of Joomla, a lot of this code is found in the Joomla core. If you take a look at the output from the core com_content component, it's not validating. And the only template in the core package that really validates out of the box is the Beez template.

Having a "broken" output from the Joomla core can mislead new developers into thinking they shouldn't care about web standards and validation. This, in turn, creates a broken window scenario.

As one developer puts it:

The best bang for buck education for new Joomla devs is (in my opinion anyway) better core code.

The most common errors

The most common error that produces warnings in the W3C validator, is the encoding of ampersands (the & character) in URLs. If you write an URL using parameters, you often use the & character. The correct use of this character in an URL is &amp;

Another thing is the use of the <br> tag, which should be <br /> in most cases.

There are many other examples of non-validating code and bad coding practice:

Tables as a lazy layout. Tables have their place, but it isn't for laying out your whole site.

Poor use of classes and IDs

Multiple IDs with the same name on a page

Javascript and CSS outside the <head> tag (exception is javascript in the footer for late loading)

and many more...

And these errors are not restricted to smaller, non-significant Joomla extensions out there. Some of the larger, high-profile extensions for Joomla are producing sloppy, non-validating code. This particularly annoys me when it happens with commercial extensions. It's like buying a car with a layer of rust beneath the paint...

What can developers do?

It's quite simple, actually. If a developer creates a module or component that outputs HTML and CSS, he should make sure that the output validates. I've seen these kinds of errors in many different types of extensions.

You could, of course, modify the code yourself to have it validate. However, that is oftentimes not within the knowledge you possess. Also, it will involve either hacking the code or making a template override. Depending on the module or component, this can produce unexpected results when upgrading.

What can you do?

As Joomla users, we can ask the developers of our favorite extensions to modify their code so it validates. I've contacted a few developers myself and given them some tips on how to do it. Most of the time, it's well received and appreciated. It shows you care, and so should they.

Also, if you have someone develop a custom Joomla extension for you, make sure they code it according to standards (and use the Joomla API). Even if it means some more development time, it will pay off in the long run.

So, I hope more developers will take the time to make sure their super-cool and nifty modules are producing validating HTML.

Related items

Recent comments

The Joomla!® name is used under a limited license from Open Source Matters in the United States and other countries.joomlablogger.net is not affiliated with or endorsed by the Joomla!® Project or Open Source Matters.The Joomla!® logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.