Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
bb3dec01
...
bb3dec01be428031d82d0cb17eb54f63da1247cb
authored
2012-05-27 09:51:39 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
removed erroneously commited file
1 parent
63f5f3be
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
48 deletions
samples/pageweight.js
samples/pageweight.js
deleted
100644 → 0
View file @
63f5f3b
/**
* Check out sizes of resources loaded on a given web page.
*
* Usage:
* $ casperjs samples/pageweight.js <url>
*/
var
casper
=
require
(
'casper'
).
create
();
var
size
=
0
;
function
kb
(
size
)
{
return
Math
.
round
(
size
/
1024
*
100
)
/
100
;
}
casper
.
on
(
'resource.received'
,
function
(
r
)
{
if
(
r
.
stage
!==
"end"
)
{
return
;
}
var
rSize
;
r
.
headers
.
forEach
(
function
(
h
)
{
console
.
log
(
h
.
name
);
});
if
(
r
.
bodySize
)
{
rSize
=
~~
r
.
bodySize
;
}
else
{
try
{
rSize
=
~~
r
.
headers
.
filter
(
function
(
h
)
{
return
h
.
name
.
toLowerCase
()
===
"content-length"
;
}).
pop
().
value
;
}
catch
(
e
)
{
// try actual content length
if
(
this
.
getCurrentUrl
()
===
r
.
url
)
{
rSize
=
casper
.
page
.
content
.
length
;
}
}
}
this
.
echo
(
r
.
url
+
': '
+
rSize
);
size
+=
rSize
||
0
;
});
casper
.
on
(
'load.finished'
,
function
(
status
)
{
this
.
echo
(
'Total: '
+
kb
(
size
)
+
'KB'
).
exit
();
});
casper
.
start
(
casper
.
cli
.
get
(
0
));
casper
.
run
(
function
()
{
});
Please
register
or
sign in
to post a comment