How Many Assets Should a Website Have?

on in Blog, SpeedFactor
Last modified on

JavaScript Code

How Many JavaScript Files Should a Website Have?

A maximum of four.

And I would still argue that is too many already. Considering the need for frameworks or site-wide libraries, four is the maximum I recommend.

If you have JavaScript code that only needs to run on specific pages, then there is no reason including it on other pages. Keep general JavaScript code into one and use Functional Programming to avoid repeating the same code in other external JavaScript files.

For mobile, aim for a JavaScript budget of <170KB minified/compressed. Uncompressed this is still ~0.7MB of code. Budgets are critical to success, however, they can’t magically fix performance in isolation. Team culture, structure and enforcement matter. Building without a budget invites performance regressions and failure.

[…] trim your JavaScript bundles. There’s a high chance you’re shipping full-libraries when you only need a fraction, polyfills for browsers that don’t need them, or duplicate code.

Addy Osmani

How Many CSS Files Should a Website Have?

A maximum of three.

Although I went for two for a recent SaaS, where one CSS file was a library (grids, UI, fonts) and the other one had custom styles.

Also, see what Chris Coyer thinks about this.

Our SpeedFactor tool allows for monitoring and tracking all these metrics and values and more and reports on their evolution on a weekly basis.

Photo by Max Nelson on Unsplash.

Related posts

WP Send

January 31, 2024

WP Send

Deep Dive into CSS Grid

March 24, 2022

Deep Dive into CSS Grid

PropTech

December 12, 2024

What is PropTech?