java比递归查询更快方法_使网站更小更快的5种方法

java比递归查询更快方法

Confession:  I'd say once a week I genuinely wish I was a kid who spent his work day cutting grass and doing landscaping.  Why?  Because at the end of the day, they are able to say "the grass is cut, the job is complete."  As Web Developers, we can't ever say that, can we?  A site can always be more efficient -- there are always strategies for eliminating bytes.  Always.  And as long as we realize that, we internally and eternally say "the site isn't good enough."  To be a great everyday developer, we're almost destined to feel as though our work isn't good enough -- what a negative way to live our lives!

告白:我真的要每周一次,我真希望我是个小孩子,他每天花一天的时间剪草和美化环境。 为什么? 因为最终,他们能够说“草被割,工作完成了”。 作为Web开发人员,我们永远不能这么说,可以吗? 网站总是可以提高效率-总是有消除字节的策略。 总是。 而且只要我们意识到这一点,我们就会在内部和外部都说“该站点不够好”。 要成为一名出色的日常开发人员,我们几乎注定会觉得我们的工作还不够出色,这是生活中一种消极的方式!

The good news is that there are a few methods for incredible easy gains in the performance and load time departments.  Here are five gains you can complete in minutes to make your site faster for all users!

好消息是,有几种方法可以使性能和加载时间部门获得难以置信的轻松收益。 您可以在几分钟之内完成五个收获,以使所有用户的网站更快!

1.壁球图像-ImageOptim (1.  Squash Images - ImageOptim)

Squashing images is the ultimate free pass in improving site load time.  Photoshop and other image editing applications are infamously inefficient with image compression, causing many KBs of extra download upon each request.  The good news is there are many utilities to eliminate those extra KBs!  My favorite Mac utility is ImageOptim.

压缩图像是改善站点加载时间的最终免费途径。 Photoshop和其他图像编辑应用程序的图像压缩效率极低,因此,每次请求都会导致许多KB的额外下载。 好消息是,有许多实用程序可以消除这些多余的KB! 我最喜欢的Mac实用程序是ImageOptim

ImageOptim

You can use gzipping as much as you'd like but extra source KB size is wasteful so using an image optimizing utility is as valuable as any other strategy you can use!

您可以随意使用gziping,但是额外的源KB大小很浪费,因此使用图像优化实用程序与您可以使用的任何其他策略一样有价值!

2. CloudFlare (2.  CloudFlare)

CloudFlare, a service that starts as free, offers loads of enhancements:

CloudFlare是一项免费的服务,它提供了许多增强功能:

  • CDN services

    CDN服务
  • JavaScript, CSS, and HTML minification

    JavaScript,CSS和HTML最小化
  • Downtime backup services

    停机备份服务
  • DDOS prevention

    DDOS预防
  • Location-based asset serving

    基于位置的资产服务

This isn't a placed advertisement -- davidwalsh.name uses Cloudflare and has used all of its features.  My site has saved GB's of data in transfer thanks to CloudFlare.  Even when my server has been down, CloudFlare has served up the pages flawlessly.  A complete win when you use CloudFlare.

不是刊登广告-davidwalsh.name使用Cloudflare并使用了其所有功能。 感谢CloudFlare,我的网站已保存了GB的传输数据。 即使我的服务器已关闭,CloudFlare仍可以完美地处理页面。 使用CloudFlare可获得完全胜利。

3.带有Fontello的较小字形图标库 (3.  Smaller Glyph Icon Libs with Fontello)

Glyph fonts have been popular for a few years now and I'll pass on listing the reasons why -- we know why they're awesome.  The problem is that we lazily use entire glyph font files whilst only using a fraction of the fonts within them.  And though we seldom consider them, font files are usually massive.  In an emoji:    :(.  Lucking utilities like Fontello exist.

字形字体已经流行了几年了,我将继续列举原因-我们知道为什么它们很棒。 问题是我们懒惰地使用整个字形字体文件,而只使用其中的一部分字体。 尽管我们很少考虑它们,但字体文件通常很大。 在表情符号中::(。像Fontello这样的幸运实用程序存在。

Fontello lets you choose individual glyphs from several glyph fonts and thus make your font icon stylesheet KBs smaller.

Fontello使您可以从几种字形字体中选择单个字形,从而使字体图标样式表KB变小。

4.生成静态文件 (4.  Generate Static Files)

We love our dynamic scripting but why serve dynamic pages when static pages will do?  This is a practice often seen with WordPress -- the post content generally doesn't change but the advertisements and comments may.

我们喜欢我们的动态脚本,但是为什么要在静态页面可以使用时提供动态页面呢? 这是WordPress常见的做法-帖子内容通常不会改变,但广告和评论可能会改变。

The answer?  Finding the key points when a page may change and generating static content when those points occur.  A sweet WordPress utility called Really Static which accomplishes this feat for the blogging platform.  Of course your non-WordPress CMS system will require custom page generation but the speed advantages will be plenty worth it.

答案? 查找页面可能更改的关键点,并在出现这些关键点时生成静态内容。 一款名为Really Static的 WordPress实用程序,可为博客平台实现这一壮举。 当然,您的非WordPress CMS系统将需要自定义页面生成,但速度优势将是值得的。

If you have content that you need to rotate in those static pages, like advertisements or links to more current content, consider JavaScript and AJAX requests to get that content -- the page will be static and the JavaScript will be served from CDN -- the only speed consideration will then be the AJAX request!

如果您有需要在这些静态页面中旋转的内容(例如广告或指向更多当前内容的链接),请考虑使用JavaScript和AJAX请求来获取该内容-该页面将是静态的,而JavaScript将通过CDN提供-只有速度考虑才是AJAX请求!

5.延迟加载资源...或嵌入? (5.  Lazyload Resources...or Embed?)

A commonly known symptom of site slowness is the number of requests each page generates.  In the past we've remedied this problem with CSS/image sprites, concatenating JavaScript and CSS resources, and using data URIs.  You could also lazyload resources or simply embed them in the page:

网站缓慢的一个常见症状是每个页面生成的请求数。 过去,我们使用CSS /图像精灵 ,连接JavaScript和CSS资源以及使用数据URI来解决此问题。 您也可以延迟加载资源或将它们简单地嵌入页面中:


document.querySelectorAll('article pre').length && (function() {
    var mediaPath = '/assets/';

    var stylesheet = document.createElement('style');
    stylesheet.setAttribute('type', 'text/css');
    stylesheet.setAttribute('rel', 'stylesheet');
    stylesheet.setAttribute('href', mediaPath + 'css/syntax.css');
    document.head.appendChild(stylesheet);

    var syntaxScript = document.createElement('script');
    syntaxScript.async = 'true';
    syntaxScript.src = mediaPath + 'js/syntax.js';
    document.body.appendChild(syntaxScript);
})();


The example above loads the syntax highlighter only if elements on the page require highlighting.  And what if the syntax highlighter CSS is just a few lines?  You could save the extra request and embed it within the page:

仅当页面上的元素需要突出显示时,以上示例才加载语法突出显示器。 如果语法突出显示CSS仅几行呢? 您可以保存额外的请求并将其嵌入页面中:


	
	<style type="text/css">
	<?php include('media/assets/highlight.css'); ?>
	</style>
</head>


Or you could concatenate the highlighter CSS to your site-wide CSS file -- either is a benefit!

或者,您也可以将荧光笔CSS连接到站点范围CSS文件中-要么是有益的!

As you can see, there are some incredibly easy speed and site gains to be had if you're willing to put in the few minutes effort to make them happen.  And when you think about the number of visitors your site gets, and then the number of pageviews, you can see why these micro-optimizations are so important!

如您所见,如果您愿意花几分钟的时间来实现目标,那么速度和站点收益将非常容易。 当您考虑网站的访问者数量,然后是网页浏览量时,您会明白为什么这些微优化如此重要!

翻译自: https://davidwalsh.name/site-speed

java比递归查询更快方法

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值