• Cleaner code is better than faster code – Web design video tutorials for beginners

    { Posted on Jun 10 2012 by seoman }
    Categories : news area

    I can’t tell you how many times that my programming experience (in Java, PHP etc) has guided me in my web design work … and strangely, even in other aspects of my life not at all related to topics ‘nerd’.

    … Ah, nerd wisdom prevails in all aspects of life.

    Anyway, here yet again, is another example where programming guides me: this time, it’s all about web design and code.


    Over the last few years, the consensus in the web design community has been to streamline code. In real terms, that comes down to:

    … The idea is to speed up web page load times and to reduce web server loads.

    This is an important goal and something all web designers should be concerned about. The problem is that if you are concentrating on optimizing your CSS or HTML to speed things up, you are concentrating on the wrong parts of your websites.

    The fact is, that most of the optimization opportunities is actually found in your images, Flash movies and other multimedia content – not the code.

    What is HTML and CSS code collapsing?

    In a nutshell:

    This is simply removing white space in your code. So you can take this:

    Web design rocks!

    Web design rocks!

    And cut it down to this:

    Web design rocks!

    Web design rocks!

    … The idea is that if you cut down 7 lines of code to just 1 line, the file will be a touch smaller. And this is true.

    This old-school technique was used back in the 1990’s when everyone was on slow dial-up Internet connections and everyone had much slower computers.

    Collapsing code was once useful, but like the transparent spacer gif trick … it is no longer needed. Actually, it’s more trouble than it is worth.

    What can web designers learn from programmers?

    When it comes to code, the web design community is still (generally) not nearly as experienced as the programming community. There are still lessons to be learned by the average web designer, lessons that have been fundamental in software development for years.

    … Programmers have known for years that when it comes to code, it is better make it cleaner than speedier, because clean code is much easier to read, write and maintain.

    So in our example above, seven lines of code are better than one.

    What is ‘cleaner’ code?

    Clean code can be broken down to:

    The rise of object oriented programming is the best example of this understanding.

    Object oriented code will almost always be slower (when running) than old school procedural programming. Nonetheless, object oriented programming now dominates the programming world and all the major languages use it including:

    … and many others.

    After decades of experience, programmers have learned through hard experience that cleaner code is much better than faster code.

    How does this apply to web design?

    Well, write cleaner css and HTML that is easier to understand and easier to work with. To repeat the list from above:

    Won’t cleaner code slow down my pages?

    The fact of the matter is, for the vast majority of websites (%99.99999999999999999) you will not see ANY difference in terms of speed or cost in bandwidth.

    … The ‘optimize code to save money’ is a wurban (Web + urban) myth.

    Stefan Mischook


    Related Posts

    Sorry, comments for this entry are closed at this time.