Why do large sites use "bad methods"?

I often see articles, posts and comments, for example:

  • Global variables do not work well in javascript tags
  • script should be at the bottom of the page
  • CSS should be in external files and at the top of the page
  • scripts should be in external files, and not in regular script -tags.
  • and etc.

I searched the HTML source of some large sites and noticed that they have a lot of simple javascript and CSS inside HTML markup. JavaScript and HTML note that they are always confusing, etc.

+8
javascript html css
source share
3 answers

There are several separate issues here.

  • What you see when you “consider the source” is usually not what they develop with. This is usually a compressed / optimized form generated from the "source" code.
  • Claims about what is “best practice” are necessarily universal and do not apply to all scenarios (especially if you are a large site and need special optimization). These guidelines should be considered individually for each project.
  • Best practice, or even clean code, does not provide a direct translation for a return on investment. It might be nice to have consistent naming schemes, but is it worth it to design and implement a scheme through 100 developers?
  • Laziness, incompetence or Friday.
+18
source share

Just because the site is large does not give any guarantees regarding the quality of the code.

Have you ever looked at the source of a Google page? It's cute? Not. Does this work? Yes!

+6
source share

Some possible reasons:

  • Some web codes are simply not very large or complex, and it really does not matter in maintainability, whether it should follow best practices or not, and it works just as it is.
  • The code is often written by inexperienced programmers, even on large, popular sites, and never improves because it works just as it is.
  • Best practices change from time to time, and they are considered wasteful to spend time reusing code just to stick to the very latest when it works just fine as it is.
  • Adding new features is considered more important than clearing the old code, especially when the old code works fine as it is.

Here you can experience a recurring theme. Rarely do programmers feel the need to fix something that is not broken.

Edit: if I wrote this now, more than two years later, I would change my mind about this last sentence to say: "Rarely does a management feel the need to fix something that is not broken." Most programmers like to update inelegant things, to the extent that they sometimes need to be limited to management in order to ship the product. I would also like to mention the concept of technical debt .

+6
source share

All Articles