3

Trying to choose the right theme: I have a main javascript file with an amount of 500kb. In this file are many functions, which are not being used on the current site.

Beside the additional load on page load: Can these unused functions slow down the performance?

Can unused functions require RAM or CPU usage on visitors end, even if they are not used, for example because they're storing variables?

6
  • Possible duplicate of what are the consequences of having unused functions Commented Jun 14, 2017 at 11:57
  • They have to be parsed and stored somewhere; yes, any additional code incurs some overhead. How much is the question and does it matter vs. incurring development overhead? Commented Jun 14, 2017 at 11:57
  • Im pretty sure that if you comment the code out, and use a minimizer, it will remove it for you Commented Jun 14, 2017 at 11:59
  • @Sandman thank you for the link! Commented Jun 14, 2017 at 11:59
  • 1
    A decent build system can possibly shake those dead functions out automatically. Commented Jun 14, 2017 at 12:25

2 Answers 2

5

Yes, because these functions are still being downloaded by the browser and stored in memory of the page in the browser.

But mind you, they probably won't have a big effect, so purging the javascript may not lead to a noticable increase, unless your users are visiting the site with a really slow internet connection or something.

Sign up to request clarification or add additional context in comments.

Comments

3

Beside the additional load on page load: Can these unused functions slow down the performance?

Beside the additional load on page load? Only if the user is on an extremely memory-starved device. 500k of JavaScript code doesn't translate into much memory usage for the parsed result at all, the effect of it sitting in memory will, in all but the most unusual environments, be effectively zero.

But two points on the thing you were leaving out with that "beside" comment:

  • Downloading the unnecessary code; could have a noticeable effect on a slower connection.
  • Parsing (and possibly compiling) the unnecessary code; could have a very small effect on the apparent page load, on a device with a really slow processor or a browser with a really slow JavaScript engine.

But effectively, in the vast majority of environments, just having the extra functions around won't cause a noticeable effect at all. It's primarily downloading the unnecessary program text that will be noticeable.

1 Comment

Crowder yes, I had the additional page load in mind. I guess I will stick around of 800-900kb page size on avada and 400-500kb on divi in the end, when I can trust in gtmetrix. Maybe I am also able to defer parsing javascript on page load, where avada automatically hits more points on gtmetrix than divi. I'd like to stick with avada, but I am a little bit afraid of these huge amount of files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.