phantomjs,作为引擎,可跨平台,以js脚本策略,命令行的执行webkit,进行页面加载和统计信息。
YSlow,分析页面元素,可对页面进行评分和评级
pagespeed, 分析页面元素,进行评分和修改建议。(nginx和apache有相关的插件,在webserver层面将对这些影响页面速度的元素进行处理,比如压缩空白,合并多个请求等)
phantomjs本身的webpage空间的时间方面,连接时间,和dns解析时间等还没有,但是webkit本身是支持webinspector,各种元素时间线都有的。如何整合待进一步研究。
Use YSlow and PhantomJS to evaluate page performance
$ wget https://github.com/downloads/marcelduran/yslow/yslow-phantomjs-3.1.1.zip
$ unzip yslow-phantomjs-3.1.1.zip
$ cp yslow.js ~/lib/js/
$ phantomjs ~/lib/js/yslow.js --info basic "http://test.example.com"
{
"w":146046,
"o":84,
"u":"http%3A%2F%2Ftest.example.com",
"r":14,
"i":"ydefault",
"lt":1103
}
overall score: B (84)
url: http://test.example.com
# of requests: 14
ruleset: ydefault
page load time: 1103
Use YSlow and PhantomJS to gather page statistics
$ phantomjs ~/lib/js/yslow.js --info stats --format plain "http://test.example.com"
size: 146.0K (146046 bytes)
overall score: B (84)
url: http://test.example.com
# of requests: 14
ruleset: ydefault
page load time: 1103
page size (primed cache): 23.8K (23828 bytes)
# of requests (primed cache): 12
statistics by component:
doc:
# of requests: 1
size: 23.8K (23828 bytes)
css:
# of requests: 2
size: 35.9K (35967 bytes)
js:
# of requests: 5
size: 79.6K (79668 bytes)
cssimage:
# of requests: 3
size: 5.0K (5071 bytes)
image:
# of requests: 2
size: 1.5K (1512 bytes)
favicon:
# of requests: 1
size: 0.0K (0 bytes)
statistics by component (primed cache):
doc:
# of requests: 1
size: 23.8K (23828 bytes)
css:
# of requests: 2
size: 0.0K (0 bytes)
js:
# of requests: 3
size: 0.0K (0 bytes)
cssimage:
# of requests: 3
size: 0.0K (0 bytes)
image:
# of requests: 2
size: 0.0K (0 bytes)
favicon:
# of requests: 1
size: 0.0K (0 bytes)
直接命令行
npm install yslow -g
yslow --info basic --format plain igvita.har
size: 67.0K (67000 bytes)
overall score: A (94)
url: http://www.igvita.com/
# of requests: 9
ruleset: ydefault
page load time: 821
Use PhantomJS and the netsniff.js to generate a HAR file
$ phantomjs ~/lib/js/netsniff.js"http://test.example.com" > ~/tmp/example.har
数据很有限,等待继续集成inspector