How can I “Reduce JavaScript execution time” of external scripts?











up vote
1
down vote

favorite












I have the feeling that there is not much I can do, but I thought I'd ask the question and see if I missed something.



How can I "Reduce JavaScript execution time" of external scripts?



When I use the PageSpeed Insights tool, my current score is 56, and one of the biggest things seems to be a problem with the execution time of some external scripts. And their caching... but that's different issue.



https://load.sumo.com
Total: 733 ms
Script Evaluation: 587 ms
Script Parse: 128 ms



https://sumo.b-cdn.net/virtual/####/client/js/services/services.js
Total: 436 ms
Script Evaluation: 212 ms
Script Parse: 90 ms



https://connect.facebook.net/signals/config/###?v=2.8.33&r=stable
Total: 215 ms
Script Evaluation: 160 ms
Script Parse: 53 ms



https://static.leadpages.net/leadboxes/current/embed.js
Total: 133 ms
Script Evaluation: 123 ms
Script Parse: 10 ms



...










share|improve this question


















  • 1




    Where are you loading the scripts? if you are loading them in the page header then they are blocking and that's a big problem. If you are loading them in the body there are optimizations that can be made, such as loading them in parallel and pre-fetching. But you are correct that there is no way to make the script do less work. All you can do is optimize when that work is done, or, remove the script and not do the work at all.
    – Matthew Herbst
    Nov 22 at 1:52










  • The scripts are loaded "correctly". Now I am just trying to understand if there is anything I can do about the JavaScript execution time, but it doesn't sound like it.
    – InsuredApple
    Nov 22 at 2:29










  • I'm not doubting that they are loading correctly. I'm saying that depending on how you load them, you can optimize how long they take to parse and execute. Parsing of the scripts is a big part of that score and can cause the user lag if it takes too long and isn't handled properly. Again, I would suggest you to please show us how you are loading the scripts, and we might be able to help you greatly reduce how much of a performance impact they have on the page, which is what it sounds like you really care about.
    – Matthew Herbst
    Nov 22 at 2:31















up vote
1
down vote

favorite












I have the feeling that there is not much I can do, but I thought I'd ask the question and see if I missed something.



How can I "Reduce JavaScript execution time" of external scripts?



When I use the PageSpeed Insights tool, my current score is 56, and one of the biggest things seems to be a problem with the execution time of some external scripts. And their caching... but that's different issue.



https://load.sumo.com
Total: 733 ms
Script Evaluation: 587 ms
Script Parse: 128 ms



https://sumo.b-cdn.net/virtual/####/client/js/services/services.js
Total: 436 ms
Script Evaluation: 212 ms
Script Parse: 90 ms



https://connect.facebook.net/signals/config/###?v=2.8.33&r=stable
Total: 215 ms
Script Evaluation: 160 ms
Script Parse: 53 ms



https://static.leadpages.net/leadboxes/current/embed.js
Total: 133 ms
Script Evaluation: 123 ms
Script Parse: 10 ms



...










share|improve this question


















  • 1




    Where are you loading the scripts? if you are loading them in the page header then they are blocking and that's a big problem. If you are loading them in the body there are optimizations that can be made, such as loading them in parallel and pre-fetching. But you are correct that there is no way to make the script do less work. All you can do is optimize when that work is done, or, remove the script and not do the work at all.
    – Matthew Herbst
    Nov 22 at 1:52










  • The scripts are loaded "correctly". Now I am just trying to understand if there is anything I can do about the JavaScript execution time, but it doesn't sound like it.
    – InsuredApple
    Nov 22 at 2:29










  • I'm not doubting that they are loading correctly. I'm saying that depending on how you load them, you can optimize how long they take to parse and execute. Parsing of the scripts is a big part of that score and can cause the user lag if it takes too long and isn't handled properly. Again, I would suggest you to please show us how you are loading the scripts, and we might be able to help you greatly reduce how much of a performance impact they have on the page, which is what it sounds like you really care about.
    – Matthew Herbst
    Nov 22 at 2:31













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have the feeling that there is not much I can do, but I thought I'd ask the question and see if I missed something.



How can I "Reduce JavaScript execution time" of external scripts?



When I use the PageSpeed Insights tool, my current score is 56, and one of the biggest things seems to be a problem with the execution time of some external scripts. And their caching... but that's different issue.



https://load.sumo.com
Total: 733 ms
Script Evaluation: 587 ms
Script Parse: 128 ms



https://sumo.b-cdn.net/virtual/####/client/js/services/services.js
Total: 436 ms
Script Evaluation: 212 ms
Script Parse: 90 ms



https://connect.facebook.net/signals/config/###?v=2.8.33&r=stable
Total: 215 ms
Script Evaluation: 160 ms
Script Parse: 53 ms



https://static.leadpages.net/leadboxes/current/embed.js
Total: 133 ms
Script Evaluation: 123 ms
Script Parse: 10 ms



...










share|improve this question













I have the feeling that there is not much I can do, but I thought I'd ask the question and see if I missed something.



How can I "Reduce JavaScript execution time" of external scripts?



When I use the PageSpeed Insights tool, my current score is 56, and one of the biggest things seems to be a problem with the execution time of some external scripts. And their caching... but that's different issue.



https://load.sumo.com
Total: 733 ms
Script Evaluation: 587 ms
Script Parse: 128 ms



https://sumo.b-cdn.net/virtual/####/client/js/services/services.js
Total: 436 ms
Script Evaluation: 212 ms
Script Parse: 90 ms



https://connect.facebook.net/signals/config/###?v=2.8.33&r=stable
Total: 215 ms
Script Evaluation: 160 ms
Script Parse: 53 ms



https://static.leadpages.net/leadboxes/current/embed.js
Total: 133 ms
Script Evaluation: 123 ms
Script Parse: 10 ms



...







javascript wordpress performance seo






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 at 1:51









InsuredApple

166




166








  • 1




    Where are you loading the scripts? if you are loading them in the page header then they are blocking and that's a big problem. If you are loading them in the body there are optimizations that can be made, such as loading them in parallel and pre-fetching. But you are correct that there is no way to make the script do less work. All you can do is optimize when that work is done, or, remove the script and not do the work at all.
    – Matthew Herbst
    Nov 22 at 1:52










  • The scripts are loaded "correctly". Now I am just trying to understand if there is anything I can do about the JavaScript execution time, but it doesn't sound like it.
    – InsuredApple
    Nov 22 at 2:29










  • I'm not doubting that they are loading correctly. I'm saying that depending on how you load them, you can optimize how long they take to parse and execute. Parsing of the scripts is a big part of that score and can cause the user lag if it takes too long and isn't handled properly. Again, I would suggest you to please show us how you are loading the scripts, and we might be able to help you greatly reduce how much of a performance impact they have on the page, which is what it sounds like you really care about.
    – Matthew Herbst
    Nov 22 at 2:31














  • 1




    Where are you loading the scripts? if you are loading them in the page header then they are blocking and that's a big problem. If you are loading them in the body there are optimizations that can be made, such as loading them in parallel and pre-fetching. But you are correct that there is no way to make the script do less work. All you can do is optimize when that work is done, or, remove the script and not do the work at all.
    – Matthew Herbst
    Nov 22 at 1:52










  • The scripts are loaded "correctly". Now I am just trying to understand if there is anything I can do about the JavaScript execution time, but it doesn't sound like it.
    – InsuredApple
    Nov 22 at 2:29










  • I'm not doubting that they are loading correctly. I'm saying that depending on how you load them, you can optimize how long they take to parse and execute. Parsing of the scripts is a big part of that score and can cause the user lag if it takes too long and isn't handled properly. Again, I would suggest you to please show us how you are loading the scripts, and we might be able to help you greatly reduce how much of a performance impact they have on the page, which is what it sounds like you really care about.
    – Matthew Herbst
    Nov 22 at 2:31








1




1




Where are you loading the scripts? if you are loading them in the page header then they are blocking and that's a big problem. If you are loading them in the body there are optimizations that can be made, such as loading them in parallel and pre-fetching. But you are correct that there is no way to make the script do less work. All you can do is optimize when that work is done, or, remove the script and not do the work at all.
– Matthew Herbst
Nov 22 at 1:52




Where are you loading the scripts? if you are loading them in the page header then they are blocking and that's a big problem. If you are loading them in the body there are optimizations that can be made, such as loading them in parallel and pre-fetching. But you are correct that there is no way to make the script do less work. All you can do is optimize when that work is done, or, remove the script and not do the work at all.
– Matthew Herbst
Nov 22 at 1:52












The scripts are loaded "correctly". Now I am just trying to understand if there is anything I can do about the JavaScript execution time, but it doesn't sound like it.
– InsuredApple
Nov 22 at 2:29




The scripts are loaded "correctly". Now I am just trying to understand if there is anything I can do about the JavaScript execution time, but it doesn't sound like it.
– InsuredApple
Nov 22 at 2:29












I'm not doubting that they are loading correctly. I'm saying that depending on how you load them, you can optimize how long they take to parse and execute. Parsing of the scripts is a big part of that score and can cause the user lag if it takes too long and isn't handled properly. Again, I would suggest you to please show us how you are loading the scripts, and we might be able to help you greatly reduce how much of a performance impact they have on the page, which is what it sounds like you really care about.
– Matthew Herbst
Nov 22 at 2:31




I'm not doubting that they are loading correctly. I'm saying that depending on how you load them, you can optimize how long they take to parse and execute. Parsing of the scripts is a big part of that score and can cause the user lag if it takes too long and isn't handled properly. Again, I would suggest you to please show us how you are loading the scripts, and we might be able to help you greatly reduce how much of a performance impact they have on the page, which is what it sounds like you really care about.
– Matthew Herbst
Nov 22 at 2:31












1 Answer
1






active

oldest

votes

















up vote
3
down vote













You won't have any control over what those external scripts do. Short of not including them, about the only thing you can do is defer their loading.



One way to do this is with the defer attribute.



<script defer src="https://example.com/script.js"></script>


This allows the page to continue to load and execute while the script is loaded and executed later. This method doesn't work with all scripts, but it will work with most. Many of the script tags you include from providers, such as Facebook, will already have alternative code which defers their loading.



See also: https://flaviocopes.com/javascript-async-defer/






share|improve this answer





















  • Thanks Brad. I've got the scripts deferred already, so that's good. I suppose that's the cost of having the functionality then.
    – InsuredApple
    Nov 22 at 2:28










  • @InsuredApple Yes. If you are a big enough fish, you can try to go yell at the people who made the scripts and get them to optimize things. Chances are though, they're already looking at the load and execution times and have optimized them quite a bit. I know for sure that Facebook is always working on optimizing their SDKs, for example.
    – Brad
    Nov 22 at 2:29













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53422834%2fhow-can-i-reduce-javascript-execution-time-of-external-scripts%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote













You won't have any control over what those external scripts do. Short of not including them, about the only thing you can do is defer their loading.



One way to do this is with the defer attribute.



<script defer src="https://example.com/script.js"></script>


This allows the page to continue to load and execute while the script is loaded and executed later. This method doesn't work with all scripts, but it will work with most. Many of the script tags you include from providers, such as Facebook, will already have alternative code which defers their loading.



See also: https://flaviocopes.com/javascript-async-defer/






share|improve this answer





















  • Thanks Brad. I've got the scripts deferred already, so that's good. I suppose that's the cost of having the functionality then.
    – InsuredApple
    Nov 22 at 2:28










  • @InsuredApple Yes. If you are a big enough fish, you can try to go yell at the people who made the scripts and get them to optimize things. Chances are though, they're already looking at the load and execution times and have optimized them quite a bit. I know for sure that Facebook is always working on optimizing their SDKs, for example.
    – Brad
    Nov 22 at 2:29

















up vote
3
down vote













You won't have any control over what those external scripts do. Short of not including them, about the only thing you can do is defer their loading.



One way to do this is with the defer attribute.



<script defer src="https://example.com/script.js"></script>


This allows the page to continue to load and execute while the script is loaded and executed later. This method doesn't work with all scripts, but it will work with most. Many of the script tags you include from providers, such as Facebook, will already have alternative code which defers their loading.



See also: https://flaviocopes.com/javascript-async-defer/






share|improve this answer





















  • Thanks Brad. I've got the scripts deferred already, so that's good. I suppose that's the cost of having the functionality then.
    – InsuredApple
    Nov 22 at 2:28










  • @InsuredApple Yes. If you are a big enough fish, you can try to go yell at the people who made the scripts and get them to optimize things. Chances are though, they're already looking at the load and execution times and have optimized them quite a bit. I know for sure that Facebook is always working on optimizing their SDKs, for example.
    – Brad
    Nov 22 at 2:29















up vote
3
down vote










up vote
3
down vote









You won't have any control over what those external scripts do. Short of not including them, about the only thing you can do is defer their loading.



One way to do this is with the defer attribute.



<script defer src="https://example.com/script.js"></script>


This allows the page to continue to load and execute while the script is loaded and executed later. This method doesn't work with all scripts, but it will work with most. Many of the script tags you include from providers, such as Facebook, will already have alternative code which defers their loading.



See also: https://flaviocopes.com/javascript-async-defer/






share|improve this answer












You won't have any control over what those external scripts do. Short of not including them, about the only thing you can do is defer their loading.



One way to do this is with the defer attribute.



<script defer src="https://example.com/script.js"></script>


This allows the page to continue to load and execute while the script is loaded and executed later. This method doesn't work with all scripts, but it will work with most. Many of the script tags you include from providers, such as Facebook, will already have alternative code which defers their loading.



See also: https://flaviocopes.com/javascript-async-defer/







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 at 1:54









Brad

113k25224383




113k25224383












  • Thanks Brad. I've got the scripts deferred already, so that's good. I suppose that's the cost of having the functionality then.
    – InsuredApple
    Nov 22 at 2:28










  • @InsuredApple Yes. If you are a big enough fish, you can try to go yell at the people who made the scripts and get them to optimize things. Chances are though, they're already looking at the load and execution times and have optimized them quite a bit. I know for sure that Facebook is always working on optimizing their SDKs, for example.
    – Brad
    Nov 22 at 2:29




















  • Thanks Brad. I've got the scripts deferred already, so that's good. I suppose that's the cost of having the functionality then.
    – InsuredApple
    Nov 22 at 2:28










  • @InsuredApple Yes. If you are a big enough fish, you can try to go yell at the people who made the scripts and get them to optimize things. Chances are though, they're already looking at the load and execution times and have optimized them quite a bit. I know for sure that Facebook is always working on optimizing their SDKs, for example.
    – Brad
    Nov 22 at 2:29


















Thanks Brad. I've got the scripts deferred already, so that's good. I suppose that's the cost of having the functionality then.
– InsuredApple
Nov 22 at 2:28




Thanks Brad. I've got the scripts deferred already, so that's good. I suppose that's the cost of having the functionality then.
– InsuredApple
Nov 22 at 2:28












@InsuredApple Yes. If you are a big enough fish, you can try to go yell at the people who made the scripts and get them to optimize things. Chances are though, they're already looking at the load and execution times and have optimized them quite a bit. I know for sure that Facebook is always working on optimizing their SDKs, for example.
– Brad
Nov 22 at 2:29






@InsuredApple Yes. If you are a big enough fish, you can try to go yell at the people who made the scripts and get them to optimize things. Chances are though, they're already looking at the load and execution times and have optimized them quite a bit. I know for sure that Facebook is always working on optimizing their SDKs, for example.
– Brad
Nov 22 at 2:29




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53422834%2fhow-can-i-reduce-javascript-execution-time-of-external-scripts%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

What visual should I use to simply compare current year value vs last year in Power BI desktop

How to ignore python UserWarning in pytest?

Alexandru Averescu