Finding Load time of website using Javascript
up vote
0
down vote
favorite
I want to find the load time of a locally hosted website. Is this way efficient? How can I display the time in a dialogue box?
<head>
<script type="text/javascript">
var loadTime = window.performance.timing.domContentLoadedEventEnd- window.performance.timing.navigationStart;
</script>
</head>
<body>
<script type="text/javascript">
window.onload = function () {
var loadTime = ((window.performance.timing.domComplete- window.performance.timing.navigationStart)/1000)+" sec.";
console.log('Page load time is '+ loadTime);
}
</script>
</body>javascript page-load-time
New contributor
Samrat Shrestha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
favorite
I want to find the load time of a locally hosted website. Is this way efficient? How can I display the time in a dialogue box?
<head>
<script type="text/javascript">
var loadTime = window.performance.timing.domContentLoadedEventEnd- window.performance.timing.navigationStart;
</script>
</head>
<body>
<script type="text/javascript">
window.onload = function () {
var loadTime = ((window.performance.timing.domComplete- window.performance.timing.navigationStart)/1000)+" sec.";
console.log('Page load time is '+ loadTime);
}
</script>
</body>javascript page-load-time
New contributor
Samrat Shrestha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
Is there a reason you don't want to use your browser developer tools for this? It's much easier to profile everything that way
– Paul
Nov 17 at 15:17
Do you mean from the network tab pressing F12? I could not get what was happening there so I wanted the easy way to read the load time.
– Samrat Shrestha
Nov 17 at 15:27
Yes, and it's far easier to see the total time plus the per resource time that way. Look for the OnDomContentLoaded number if your browser supports it for the effective total render
– Paul
Nov 17 at 15:44
Does the developer tool give accurate load time?
– Samrat Shrestha
Nov 17 at 16:06
Yes, they do. In all modern browsers
– Paul
Nov 17 at 16:20
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to find the load time of a locally hosted website. Is this way efficient? How can I display the time in a dialogue box?
<head>
<script type="text/javascript">
var loadTime = window.performance.timing.domContentLoadedEventEnd- window.performance.timing.navigationStart;
</script>
</head>
<body>
<script type="text/javascript">
window.onload = function () {
var loadTime = ((window.performance.timing.domComplete- window.performance.timing.navigationStart)/1000)+" sec.";
console.log('Page load time is '+ loadTime);
}
</script>
</body>javascript page-load-time
New contributor
Samrat Shrestha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I want to find the load time of a locally hosted website. Is this way efficient? How can I display the time in a dialogue box?
<head>
<script type="text/javascript">
var loadTime = window.performance.timing.domContentLoadedEventEnd- window.performance.timing.navigationStart;
</script>
</head>
<body>
<script type="text/javascript">
window.onload = function () {
var loadTime = ((window.performance.timing.domComplete- window.performance.timing.navigationStart)/1000)+" sec.";
console.log('Page load time is '+ loadTime);
}
</script>
</body><head>
<script type="text/javascript">
var loadTime = window.performance.timing.domContentLoadedEventEnd- window.performance.timing.navigationStart;
</script>
</head>
<body>
<script type="text/javascript">
window.onload = function () {
var loadTime = ((window.performance.timing.domComplete- window.performance.timing.navigationStart)/1000)+" sec.";
console.log('Page load time is '+ loadTime);
}
</script>
</body><head>
<script type="text/javascript">
var loadTime = window.performance.timing.domContentLoadedEventEnd- window.performance.timing.navigationStart;
</script>
</head>
<body>
<script type="text/javascript">
window.onload = function () {
var loadTime = ((window.performance.timing.domComplete- window.performance.timing.navigationStart)/1000)+" sec.";
console.log('Page load time is '+ loadTime);
}
</script>
</body>javascript page-load-time
javascript page-load-time
New contributor
Samrat Shrestha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Samrat Shrestha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Samrat Shrestha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked Nov 17 at 15:15
Samrat Shrestha
266
266
New contributor
Samrat Shrestha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Samrat Shrestha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Samrat Shrestha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
Is there a reason you don't want to use your browser developer tools for this? It's much easier to profile everything that way
– Paul
Nov 17 at 15:17
Do you mean from the network tab pressing F12? I could not get what was happening there so I wanted the easy way to read the load time.
– Samrat Shrestha
Nov 17 at 15:27
Yes, and it's far easier to see the total time plus the per resource time that way. Look for the OnDomContentLoaded number if your browser supports it for the effective total render
– Paul
Nov 17 at 15:44
Does the developer tool give accurate load time?
– Samrat Shrestha
Nov 17 at 16:06
Yes, they do. In all modern browsers
– Paul
Nov 17 at 16:20
add a comment |
1
Is there a reason you don't want to use your browser developer tools for this? It's much easier to profile everything that way
– Paul
Nov 17 at 15:17
Do you mean from the network tab pressing F12? I could not get what was happening there so I wanted the easy way to read the load time.
– Samrat Shrestha
Nov 17 at 15:27
Yes, and it's far easier to see the total time plus the per resource time that way. Look for the OnDomContentLoaded number if your browser supports it for the effective total render
– Paul
Nov 17 at 15:44
Does the developer tool give accurate load time?
– Samrat Shrestha
Nov 17 at 16:06
Yes, they do. In all modern browsers
– Paul
Nov 17 at 16:20
1
1
Is there a reason you don't want to use your browser developer tools for this? It's much easier to profile everything that way
– Paul
Nov 17 at 15:17
Is there a reason you don't want to use your browser developer tools for this? It's much easier to profile everything that way
– Paul
Nov 17 at 15:17
Do you mean from the network tab pressing F12? I could not get what was happening there so I wanted the easy way to read the load time.
– Samrat Shrestha
Nov 17 at 15:27
Do you mean from the network tab pressing F12? I could not get what was happening there so I wanted the easy way to read the load time.
– Samrat Shrestha
Nov 17 at 15:27
Yes, and it's far easier to see the total time plus the per resource time that way. Look for the OnDomContentLoaded number if your browser supports it for the effective total render
– Paul
Nov 17 at 15:44
Yes, and it's far easier to see the total time plus the per resource time that way. Look for the OnDomContentLoaded number if your browser supports it for the effective total render
– Paul
Nov 17 at 15:44
Does the developer tool give accurate load time?
– Samrat Shrestha
Nov 17 at 16:06
Does the developer tool give accurate load time?
– Samrat Shrestha
Nov 17 at 16:06
Yes, they do. In all modern browsers
– Paul
Nov 17 at 16:20
Yes, they do. In all modern browsers
– Paul
Nov 17 at 16:20
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
@Samrat Shrestha This snippet work for you
<doctype html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<head>
<script type="text/javascript">
$(document).ready(function() {
console.log("Time until DOMready: ",window.performance.timing.loadEventEnd-window.performance.timing.navigationStart);
});
</script>
<!-- do all the stuff you need to do -->
</head>
<body>
</body>
</html>
The ready event occurs after the HTML document has been loaded.
window.onload fires when the entire page loads (images, styles, etc.)
window.onload vs $(document).ready()
https://developer.mozilla.org/en-US/docs/Web/API/Navigation_timing_API#Examples
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceTiming/loadEventEnd
New contributor
Syed Ausaf Hussain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
@Samrat Shrestha This snippet work for you
<doctype html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<head>
<script type="text/javascript">
$(document).ready(function() {
console.log("Time until DOMready: ",window.performance.timing.loadEventEnd-window.performance.timing.navigationStart);
});
</script>
<!-- do all the stuff you need to do -->
</head>
<body>
</body>
</html>
The ready event occurs after the HTML document has been loaded.
window.onload fires when the entire page loads (images, styles, etc.)
window.onload vs $(document).ready()
https://developer.mozilla.org/en-US/docs/Web/API/Navigation_timing_API#Examples
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceTiming/loadEventEnd
New contributor
Syed Ausaf Hussain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
@Samrat Shrestha This snippet work for you
<doctype html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<head>
<script type="text/javascript">
$(document).ready(function() {
console.log("Time until DOMready: ",window.performance.timing.loadEventEnd-window.performance.timing.navigationStart);
});
</script>
<!-- do all the stuff you need to do -->
</head>
<body>
</body>
</html>
The ready event occurs after the HTML document has been loaded.
window.onload fires when the entire page loads (images, styles, etc.)
window.onload vs $(document).ready()
https://developer.mozilla.org/en-US/docs/Web/API/Navigation_timing_API#Examples
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceTiming/loadEventEnd
New contributor
Syed Ausaf Hussain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
up vote
0
down vote
@Samrat Shrestha This snippet work for you
<doctype html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<head>
<script type="text/javascript">
$(document).ready(function() {
console.log("Time until DOMready: ",window.performance.timing.loadEventEnd-window.performance.timing.navigationStart);
});
</script>
<!-- do all the stuff you need to do -->
</head>
<body>
</body>
</html>
The ready event occurs after the HTML document has been loaded.
window.onload fires when the entire page loads (images, styles, etc.)
window.onload vs $(document).ready()
https://developer.mozilla.org/en-US/docs/Web/API/Navigation_timing_API#Examples
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceTiming/loadEventEnd
New contributor
Syed Ausaf Hussain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
@Samrat Shrestha This snippet work for you
<doctype html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<head>
<script type="text/javascript">
$(document).ready(function() {
console.log("Time until DOMready: ",window.performance.timing.loadEventEnd-window.performance.timing.navigationStart);
});
</script>
<!-- do all the stuff you need to do -->
</head>
<body>
</body>
</html>
The ready event occurs after the HTML document has been loaded.
window.onload fires when the entire page loads (images, styles, etc.)
window.onload vs $(document).ready()
https://developer.mozilla.org/en-US/docs/Web/API/Navigation_timing_API#Examples
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceTiming/loadEventEnd
New contributor
Syed Ausaf Hussain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited Nov 18 at 9:10
New contributor
Syed Ausaf Hussain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered Nov 17 at 18:05
Syed Ausaf Hussain
366
366
New contributor
Syed Ausaf Hussain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Syed Ausaf Hussain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Syed Ausaf Hussain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
Samrat Shrestha is a new contributor. Be nice, and check out our Code of Conduct.
Samrat Shrestha is a new contributor. Be nice, and check out our Code of Conduct.
Samrat Shrestha is a new contributor. Be nice, and check out our Code of Conduct.
Samrat Shrestha is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53352540%2ffinding-load-time-of-website-using-javascript%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Is there a reason you don't want to use your browser developer tools for this? It's much easier to profile everything that way
– Paul
Nov 17 at 15:17
Do you mean from the network tab pressing F12? I could not get what was happening there so I wanted the easy way to read the load time.
– Samrat Shrestha
Nov 17 at 15:27
Yes, and it's far easier to see the total time plus the per resource time that way. Look for the OnDomContentLoaded number if your browser supports it for the effective total render
– Paul
Nov 17 at 15:44
Does the developer tool give accurate load time?
– Samrat Shrestha
Nov 17 at 16:06
Yes, they do. In all modern browsers
– Paul
Nov 17 at 16:20