You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vararr=newArray(1000),len,i;for(i=0;i<arr.length;i++){// Bad - size needs to be recalculated 1000 times}for(i=0,len=arr.length;i<len;i++){// Good - size is calculated only 1 time and then stored}
varlinks=document.getElementsByTagName('a'),len,i;for(i=0;i<links.length;i++){// Bad - each iteration the list of links will be recalculated to see if there was a change}for(i=0,len=links.length;i<len;i++){// Good - the list size is first obtained and stored, then compared each iteration}// Terrible: infinite loop examplefor(i=0;i<links.length;i++){document.body.appendChild(document.createElement('a'));// each iteration the list of links increases, never satisfying the termination condition of the loop// this would not happen if the size of the list was stored and used as a condition}
避免使用document.write
...
最小化重绘和重画
...
避免不必要的dom操作
// really bad!for(vari=0;i<100;i++){document.getElementById("myList").innerHTML+="<span>"+i+"</span>";}// much better :)varmyList="";for(vari=0;i<100;i++){myList+="<span>"+i+"</span>";}document.getElementById("myList").innerHTML=myList;
Confess - Uses PhantomJS to headlessly analyze web pages and generate manifests.
Page Speed - The PageSpeed family of tools is designed to help you optimize the performance of your website. PageSpeed Insights products will help you identify performance best practices that can be applied to your site, and PageSpeed optimization tools can help you automate the process.
YSlow - YSlow analyzes web pages and suggests ways to improve their performance based on a set of rules for high performance web pages.
YSlow for PhantomJS - YSlow for PhantomJS also introduces new output formats for automated test frameworks: TAP (Test Anything Protocol) and JUnit.
Grunt-yslow - Grunt task for testing page performance using PhantomJS, a headless WebKit browser.
Grunt-perfbudget - A Grunt.js task for enforcing a performance budget (more on performance budgets).
Web Tracing Framework - Web Tracing Framework is a set of libraries, tools, and visualizers for the tracing and investigation of complex web applications.
前端性能优化方案介绍
大家当然知道它很重要。所以为什么我们还要做出速度很慢的网站,给用户一个糟糕的体验呢?
## Let's Go On
- 页面级优化 - 服务器级优化 - html优化 - CSS优化 - Javascript优化 - 图片优化 - BONUS - ...
## 页面级优化
## 服务器级优化
## html优化
## CSS优化
## Javascript优化
## 图片优化
## BONUS
后续
END
THX & Q & A
The text was updated successfully, but these errors were encountered: