Search code examples
javascriptcsshtmlweb-optimization

How big should a file be before I don't inline it in html?


Google recommends optimising web pages by inlining small CSS & javascript.

Ref: https://developers.google.com/speed/pagespeed/service/InlineSmallResources

But at what point should we stop inlining, is there a recommended maximum number of characters that a file should be before it is better to reference instead of inline the file?


Solution

  • Obviously this isn't a complete list, but I think this is a decent set of guidelines.

    Situations when inlining might be beneficial:

    Situations when inlining might be harmful:

    • Styles or scripts are used on multiple pages - if inlined on each page, they will not be cached and need to be downloaded again on each page