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