八岐大蛇蛇的伤害算谁的伤害_避免诱惑损害网站性能

news/2024/5/20 3:09:27/文章来源:https://blog.csdn.net/culi3118/article/details/108383056

八岐大蛇蛇的伤害算谁的伤害

SitePoint recently published Lean Websites, by Barbara Bermes—a book that presents the latest techniques for improving web page performance. In this article, Barbara details some of the performance pitfalls that all too often catch us unawares.

SitePoint最近出版了Barbara Bermes撰写的《 精益网站》 ,该书介绍了改善网页性能的最新技术。 在本文中,Barbara详细介绍了一些性能陷阱,这些陷阱经常使我们无所适从。



Web performance matters. Studies have shown that improvements in website performance—such as page load times—can dramatically increase user engagement and profits.

网络性能很重要。 研究表明 ,网站性能的改善(例如页面加载时间)可以大大提高用户的参与度和利润。

However, life's short, and time is money. As web developers, we're paid to get the job done—by clients, bosses and colleagues who may not appreciate the importance of site performance. So the temptation is to cut corners to get the job done—to find the quickest solution, without regard for performance. In these times of rising mobile usage and search engine preference for lean websites, average page weights continue to soar. It's not a good situation.

但是,生命短暂,时间就是金钱。 作为Web开发人员,我们为完成工作而付费—由可能不了解网站性能重要性的客户,老板和同事完成。 因此,诱惑在于偷工减料来完成工作-寻找最快捷的解决方案,而不考虑性能。 在当今移动使用率上升和搜索引擎偏爱精益网站的时代, 平均页面权重持续飙升 。 这不是一个好情况。

Temptation: the pressure to give in to a desire for easy or immediate pleasure

诱惑:屈服于渴望轻松​​或即刻享受的压力

The consequences of giving in to temptation are often not felt until afterwards.

屈服于诱惑的后果往往直到事后才感受到。

This article describes some of the temptations you've probably faced in your web development journey, and why it's better not to give in to them.

本文介绍了您在Web开发过程中可能遇到的一些诱惑,以及为什么最好不要屈服于它们。

使用现成的脚本 (Using Ready-made Scripts)

It's a typical scenario: you need to add something to a web page—such as a slideshow. So you google "web slideshow" and get hundreds of results. There are so many to choose from, all ready to go, and free. Why not just use one as is, save time, and get paid? Doesn't everyone else?

这是一个典型的场景:您需要在网页上添加一些内容,例如幻灯片。 因此,您使用Google“网络幻灯片”并获得了数百个结果。 有很多可供选择的选择,并且都可以免费使用。 为什么不按原样使用它,节省时间并获得报酬? 难道不是所有人吗?

We often forget to consider the performance of the scripts we choose. Is the code well written? Is it optimized? Do we need all the functionality it contains?

我们经常忘记考虑我们选择的脚本的性能。 代码编写正确吗? 优化了吗? 我们需要它包含的所有功能吗?

In Chapter 4 of Lean Websites, I examine how to differentiate between copy and paste and copy and waste.

精益网站的第4章中,我研究如何区分复制和粘贴以及复制和浪费

漂亮的图像和设计 (Pretty Images and Designs)

A picture is worth a thousands words; and when it comes to web performance, a picture might be worth more that a thousand lines of code in terms of page weight! Poorly optimized images are by far the the biggest cause of bloated websites.

一幅画值得一千个字; 就网页性能而言,一张图片的页面权重可能超过一千行代码! 到目前为止,优化效果不佳的图片是网站膨胀的最大原因。

There are some image considerations that can make a huge difference to web page performance.

有一些图像注意事项可能会对网页性能产生巨大影响。

并非每个设备都需要高分辨率 (Not Every Device Needs a High Resolution)

There's no need to show everybody the high resolution version of the image if not needed. Be context sensitive, considerate and respectful. Don't fill your page with unnecessary heavy assets like images just because you don't know what else to put there. Trust me, none of your users on their mobile device while roaming wants to download a 2MB retina image.

如果不需要,则无需向所有人显示图像的高分辨率版本。 对上下文敏感,体贴和尊重。 不要仅仅因为您不知道还需要放置什么东西而在页面上填充不必要的繁重资产(例如图像)。 相信我,漫游时您移动设备上的所有用户都不希望下载2MB的视网膜图像。

图片费用带宽 (Images Cost Bandwidth)

Images remain the biggest performance culprits. They currently take up most of the file sizes and usage on the internet, as shown in the chart below:

图像仍然是最大的性能元凶。 它们目前占用互联网上的大多数文件大小和使用情况,如下图所示:

Bandwidth usage of various content types

Bandwidth usage of various content types

各种内容类型的带宽使用

The temptation web developers face, especially when working under a lot of time pressure, is to just plug in big images, without considering whether to convert them into a more efficient image dimension or format.

Web开发人员面临的诱惑,尤其是在大量时间压力下工作时,面临的诱惑是仅插入大图像,而不考虑是否将其转换为更有效的图像尺寸或格式。

In my book Lean Websites, I look in depth at ways to optimize your images and other site assets to ensure that your site is as performant as possible—especially on devices connected to mobile networks.

在我的《 精益网站》一书中,我深入探讨了优化图像和其他网站资产以确保您的网站性能最佳的方法,尤其是在连接到移动网络的设备上。

性能优化是开发的一部分 (Performance Optimization as a Part of Development)

When time is money, there's always a temptation to cut corners. One way to cut corners is to put things off and never end up doing them. Performance testing and optimizing are critical, but it's tempting to put them off till later and then forget all about them.

当时间就是金钱时,总会有偷工减料的诱惑。 偷工减料的一种方法是拖延时间,永远不要结束。 性能测试和优化是至关重要的,但是很容易将它们推迟到以后再忘记。

Performance optimization is often not mentioned as part of the common software development life cycle at all. But as Ilya Grigorik says, "performance is a feature", and shouldn't be relegated to an afterthought.

通常在通用软件开发生命周期中根本没有提到性能优化。 但是正如Ilya Grigorik所说,“ 性能是一项功能 ”,不应将其归于事后。

Lean Websites discusses how you can automate optimization, and make it part of your deployment process, with some easy-to-use and free tools.

精益网站讨论了如何使用一些易于使用且免费的工具来自动执行优化,并将其纳入部署过程。

库和框架 (Libraries and Frameworks)

Christian Heilmann, a web evangelist at Microsoft, calls it "death by a thousand plugins". It's so easy to attempt to use modern web development trends by including yet another plugin or library. We sometimes forget that anything you put on your page will cost you and your visitor when it comes to performance. Don't let too many plugins bloat your website. Heilmann also encourages us to remember that "it is not about what you can add—it is about what we can’t take away". Something to remember next time when you want to paste another plugin into your site.

微软的网络传播者克里斯蒂安·海尔曼(Christian Heilmann)称其为“ 千个插件导致的死亡 ”。 通过包含另一个插件或库,尝试使用现代Web开发趋势非常容易。 有时我们会忘记,放到页面上的任何内容都会使您和访客失去性能。 不要让太多的插件at肿您的网站。 Heilmann还鼓励我们记住“这不是您可以添加的内容,而是我们不能带走的内容”。 下次要将其他插件粘贴到您的站点时要记住的事情。

Libraries like jQuery, Dojo, and YUI are popular tools that help developers kick-start JavaScript projects, making access to JavaScript objects and methods faster and easier. They simplify the coding experience—but at what cost?

诸如jQuery,Dojo和YUI之类的库是流行的工具,可帮助开发人员启动JavaScript项目,从而使访问JavaScript对象和方法的速度更快,更容易。 它们简化了编码体验,但是要花多少钱呢?

Big Query query

Most popular libraries

最受欢迎的图书馆

The file size of these libraries may vary a lot, especially if they are not minified, gzipped and compressed. jQuery minified and compressed is almost eight times smaller than sending it over the wire without optimization (252 KB uncompressed, 32 KB minified and gzipped).

这些库的文件大小可能相差很大,尤其是如果未缩小,压缩和压缩它们的话。 缩小和压缩的jQuery几乎比未经优化通过网络发送的jQuery小八倍(252 KB未压缩,32 KB缩小并压缩)。

It's important to decide what framework or library to use early on in a project. It normally doesn't make sense to use more than one library or more than one MVC JavaScript framework with a project, as different libraries tend to achieve the same goal. And of course, a library should only be loaded once, though it's not uncommon to see multiple instances of jQuery on a single page:

决定在项目的早期使用哪种框架或库很重要。 通常,在一个项目中使用不止一个库或不止一个MVC JavaScript框架是没有意义的,因为不同的库往往会实现相同的目标。 当然,一个库只应加载一次,尽管在单个页面上看到多个jQuery实例并不罕见:

WebsiteCountDifferent jQuery version loaded
www.reddit.com21.7.2,1.7.1
www.washingtontimes.com21.4.2,1.4.4
www.tudoseo.com101.6.2,1.7.2,1.7.1,1.6.4,1.8.2,
1.4.2,1.10.1,1.4.4,1.9.0,1.8.3
网站 计数 加载了不同的jQuery版本
www.reddit.com 2 1.7.2,1.7.1
www.washingtontimes.com 2 1.4.2,1.4.4
www.tudoseo.com 10 1.6.2,1.7.2,1.7.1,1.6.4,1.8.2,
1.4.2,1.10.1,1.4.4,1.9.0,1.8.3

Duplicate loading of jQuery, source: example Google Big Query on HTTP Archive for the month of July 2014

重复加载jQuery,来源:2014年7月月份HTTP存档上的Google Big Query示例

Why would you want to load more than one version of jQuery? Isn't this screaming for a good clean-up? There is definitely some legacy code in there that might require an older version of jQuery. Hence, the temptation is pretty big to just add a new version in addition to use newer functionality in jQuery. That seems like a lot of maintenance and legacy trouble. Instead, take some time, go through the functionality of your site and determine which version to convert to.

您为什么要加载多个版本的jQuery? 这不是在要求良好的清理吗? 肯定有一些旧代码可能需要旧版本的jQuery。 因此,除了在jQuery中使用较新的功能之外,仅添加新版本的诱惑也很大。 这似乎是很多维护和遗留问题。 相反,请花一些时间浏览网站的功能,然后确定要转换为哪个版本。

While sometimes there might be a good reason to include several JavaScript frameworks, there could also be other reasons that should be verified. The overlapping and duplication of plugins can stem from different reasons:

尽管有时有充分的理由要包含多个JavaScript框架,但也有其他理由应加以验证。 插件的重叠和重复可能源于不同的原因:

  • The team building the site didn't agree on a common framework or library to use.

    建立站点的团队不同意要使用的通用框架或库。
  • Tangled code that developers have to work with. Sometimes they are only being provided with isolated include files, with very little visibility to the parent code. They could be tempted to just plug in their preferred library and version if needed, to continue their work.

    开发人员必须使用的复杂代码。 有时,仅为它们提供隔离的包含文件,而对父代码的可见性很小。 如果需要的话,他们可能会愿意插入他们喜欢的库和版本来继续工作。
  • Missing enforcement techniques.

    缺少执法技术。
  • Carelessness or laziness of developers.

    开发人员的粗心或懒惰。
  • Use of other web components including the same frameworks.

    使用其他Web组件,包括相同的框架。

Lean Websites looks in detail at the consequences of using libraries and frameworks, and how to make the best use of them without negatively impacting on site performance.

精益网站详细研究了使用库和框架的后果,以及如何在不对站点性能产生负面影响的情况下充分利用它们。

社交媒体,广告和跟踪 (Social Media, Ads and Tracking)

If you work for a company with a business intelligence, analytics or marketing department, the chances are high that you are being asked to include anything that could help measure the company's success.

如果您在一家拥有商业智能,分析或市场营销部门的公司工作,则很可能会要求您提供任何有助于衡量公司成功的信息。

Social media, ads and tracking scripts are big temptations for marketers and companies to better understand their customers and to add or find other revenue streams, such as selling ads. But any foreign content you add on top of your own content—especially if it's JavaScript-based—will add weight and load time to your page.

社交媒体,广告和跟踪脚本是营销人员和公司更好地了解其客户并增加或找到其他收入来源(例如销售广告)的巨大诱惑。 但是,您在自己的内容之上添加的任何外国内容(尤其是基于JavaScript的内容)都会增加页面的权重和加载时间。

There's not one social media or tracking tool out there that marketing wouldn't like to try out. Lean Websites looks in detail at how to properly and securely include third-party scripts and plugins.

那里没有一种社交媒体或跟踪工具是营销不想尝试的。 精益网站详细介绍了如何正确,安全地包含第三方脚本和插件。

A handy rule of thumb is that the value you get from using a third party script has to be greater than its performance hit.

一个方便的经验法则是,使用第三方脚本获得的价值必须大于其对性能的影响。

结论 (Conclusion)

Performance optimization is often an exercise in compromise, and there are always competing interests to be considered.

性能优化通常是一种折衷的方法,并且始终存在需要考虑的竞争利益。

This article has raised just a few of the issues involved in site optimization—a topic that is finally coming of age in a big way.

本文仅提出了一些与网站优化有关的问题,这个问题终于在很大程度上成熟了。

Lean Websites provides a detailed, in-depth overview of the many factors involved in creating efficient, performant websites—from understanding user experience and expectations to monitoring performance, automating tasks, and optimizing server requests, site assets, and the networks our sites run on.

精益网站详细,深入地概述了创建高效,高性能网站所涉及的许多因素,从了解用户体验和期望到监视性能,自动化任务以及优化服务器请求,网站资产和我们网站运行的网络。

Hopefully this this brief introduction has whetted your appetite to find out more! I'd love to field any questions or comments you may have.

希望这个简短的介绍能激发您的胃口,以了解更多信息! 我很乐意回答您可能提出的任何问题或意见。

翻译自: https://www.sitepoint.com/avoiding-temptations-harm-website-performance/

八岐大蛇蛇的伤害算谁的伤害

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_785184.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

css gpu加速_五个CSS性能工具可加速您的网站

css gpu加速This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible. 本文是与SiteGround合作创建的系列文章的一部分。 感谢您支持使SitePoint成为可能的合作伙伴。 In this article…

php网站开发架构_PHP的干净代码架构和测试驱动开发

php网站开发架构The Clean Code Architecture was introduced by Robert C. Martin on the 8light blog. The idea was to create an architecture which is independent of any external agency. Your business logic should not be coupled to a framework, a database, or t…

小型企业服务器选择_小型企业的最佳免费和廉价网站选择

小型企业服务器选择Not long ago, if you wanted a website, you had to be willing to shell out at least a few grand for the most basic of static sites. I remember about ten years ago at a firm I worked for, quotes for ecommerce sites, or sites with other dyna…

cms数据库设计_使用Statamic CMS构建无数据库的网站

cms数据库设计A content management system (CMS) is a package of code around which you build a dynamic website—with components that change, adapt and update automatically, in contrast to a hard-coded, static site. 内容管理系统(CMS)是一揽子代码,您…

编辑器生成静态网页_使用静态网站生成器的7个理由

编辑器生成静态网页Static site generators have become increasingly popular and, if my prediction is correct, usage will explode during 2016. Let’s establish what we mean by the term “static site generator” … 静态站点生成器已变得越来越流行,如果…

wordpress 自定义_为您的WordPress网站设计自定义主页

wordpress 自定义WordPress is used on a large portion of sites on the web. It allows us to create a variety of different types of sites, but one of the most important components of any website is always the home page. The perfect landing page will help you …

编辑器生成静态网页_不使用静态网站生成器的7个理由

编辑器生成静态网页Trending posts on SitePoint today: 今天在SitePoint上的热门帖子: 7 Ways to Make WordPress Simpler for Users 为用户简化WordPress的7种方法 I Need a Website. What Do I Need to Know About Hosting? 我需要一个网站。 关于托管我需要了…

wordpress插件_审查的顶级WordPress SEO插件

wordpress插件WordPress provides great native SEO features, so might your theme. However, by using a dedicated SEO plugin (and knowing how to use it) we can further optimize our site. In this article we compare the top SEO plugins for WordPress side-by-side…

如何安装和使用WP-CLI来管理WordPress网站

Speeding up your work process should be one of your top priorities. Simply put, if you do more work in less time, then you will have more time to work on more projects, study and rest. 加快工作流程应该是您的首要任务之一。 简而言之,如果您用更少的…

wordpress快速建站_快速提示:使用WordPress联络表7增强选择加入

wordpress快速建站You might have heard the saying, “the money is in the list”. Your email list, to be exact. Email marketing is widely considered to be the most powerful form of marketing today, and there are plenty of stats to back it up. 您可能已经听说过…

php网站功能块学习_学习PHP 7,了解新功能等

php网站功能块学习PHP 7, the next version of the world’s most popular programming language, has been released. We’d love to shoot fireworks and get drunk with our newfound power (seriously, the language is in the true big leagues now, functionality and pe…

wordpress网站迁移_如何将您的WordPress网站迁移到新的托管服务提供商

wordpress网站迁移This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible. 本文是与SiteGround合作创建的系列文章的一部分。 感谢您支持使SitePoint成为可能的合作伙伴。 We’ve be…

wordpress 静态化_地理定位WordPress内容以个性化您的网站

wordpress 静态化So what does that phrase mean, “Geo-Targeting WordPress Content”? First, let’s back up and look at an example of personalization. 那么,这句话是什么意思,“以地理定位的WordPress内容”? 首先,让我…

next主题seo优化_SEO可见性的5个最佳WordPress主题

next主题seo优化This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible. 本文是与SiteGround合作创建的系列文章的一部分。 感谢您支持使SitePoint成为可能的合作伙伴。 Theme selec…

cloudflare_使用Cloudflare使您的网站更快,更安全

cloudflareCloudflare is an industry leader in the content-delivery space, reducing load and speeding up millions of websites. Cloudflare是内容交付领域的行业领导者,可减轻负载并加快数百万个网站的速度。 What is peculiar about this provider is that…

六个最受欢迎的 CMS 建站系统,不容错过|Gitee项目推荐

CMS 是 Content Management System 的缩写,意为"内容管理系统"。 内容管理系统是企业信息化建设和电子政务的新宠,也是一个相对较新的市场。对于内容管理,业界还没有一个统一的定义,不同的机构有不同的理解。CMS 在各行…

html 相对路径 网站根目录,html中的绝对路径URL和相对路径URL及子目录、父目录、根目录...

绝对URL用于表示Internet中特定文件所需要的全部内容,Internet中的每一个文件都有一个唯一的URL,这就是在网页中搜索时需要输入到地址栏的连接。例如,要进入百度一下的网页,则在网页地址栏中输入:即可。一旦进入到某个…

php网站整合ck播放器,网页视频播放器-ckplayer 整合到wordpress

在这里我将教大家怎样将这款播放器整合到wordpress中来,并教大家怎么将优酷视频用到这款播放器上面!第一步:我们要下载一个播放器文件第二步:将下载文件解压出来,打开里面player文件夹下ckplayer.txt文本文档,将里面的…

【最新】某素材网站上的虎年高质量海报素材合集,附带源文件和预览图

原格式PSD提供给大家同时提供jpg预览图,马上过年了,这套素材用的上,红色喜庆 醉了,本来想整理的上传的,但是发现有水印,现在水印已经全部去除,放心食用,每个图都比较大,一…

使用SSM重新开发计科院网站

一、游览 在游览器地址栏输入:http://localhost:8080/index,即访问计科院首页,由于前期对数据库以及JavaBean的设计考虑不够充分,导致后期的代码臃肿,所以项目启动时对首页进行数据的填充难以实现,必须输入…