JavaScript JavaScript Basics Storing and Tracking Information with Variables Spaces, tabs and new lines in JavaScript

Sheila Katzaman
Sheila Katzaman
4,560 Points

Does adding extra space cause slower web page load time?

The company I work for works with a developer company that writes all our code for our website. Through some research, we discovered our website load time isn't best practice and cleaning up some of our JavaScript can help that. Does the amount of space in JavaScript code count toward the "weight" of the code itself or is the "weight" of the code based on characters written?

1 Answer

Steven Parker
Steven Parker
162,936 Points

The loading time is a factor of the total number of characters, both visible and white space.

A standard optimizing practice is to reduce file size which includes removing all unnecessary white space. A file processed this way is called "minified", and there are several utilities available to assist with this both online and downloadable.

Minified files are difficult to maintain, so the original source should always be kept for doing any further development. The updated file can be minified again before publishing.

Sheila Katzaman
Sheila Katzaman
4,560 Points

Thank you. That makes total sense.