Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

Sheila Katzaman
Sheila Katzaman
6,441 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
229,783 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
6,441 Points

Thank you. That makes total sense.