为什么大网站使用“不良做法”? [英] Why do big sites use 'bad practices'?

查看:110
本文介绍了为什么大网站使用“不良做法”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常看到类似的文章,讯息和评论:

I often see articles, posts and comments something like:


  • 全域性在JavaScript中不佳

  • 脚本标记应在页面底部

  • CSS应位于外部文件中,位于页面顶部

  • 脚本应位于外部文件,而不是纯文本标记。

  • 等。

  • globals are bad in javascript
  • script tags should be at bottom of page
  • CSS should be in external files and at the top of page
  • scripts should be in external files, not plain script-tags.
  • etc.

来源的一些大网站,并注意到他们有很多纯HTML和HTML标记的javascript和CSS。

I've looked up the HTML source of some big sites and have noticed that they have a lot of plain javascript and CSS inside HTML markup. JavaScript and HTML are note always obfuscated, and so on.

推荐答案

这里有很多不同的问题。

There are quite a few separate issues here.


  1. 当你查看源代码时,你看到的通常不是他们开发的。它通常是从源代码生成的压缩/优化形式。

  2. 关于什么是最佳实践的声明一定是通用的,不适用于所有场景需要专门的优化)。

  3. 最佳做法,甚至干净的代码,不会直接转化为投资回报率。

  4. 懒惰,无能,或周五晚上。
  5. $ b $ b
  1. What you see when you "view source" is not usually what they develop with. It's usually a compressed / optimised form generated from "source" code.
  2. Claims about what is "best practice" are necessarily generic, and don't apply to all scenarios (especially if you're a big site and need specialised optimisation). These guidelines should be considered individually for each project.
  3. Best practice, or even clean code, doesn't directly translate to return on investment. It may be nice to have consistent naming schemes, but is it worth the time developing and enforcing the scheme across 100s of developers?
  4. Laziness, incompetence, or Friday nights.

这篇关于为什么大网站使用“不良做法”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆