0

I have following assets:

  • Preloaded local javascript - <link rel="preload" as="script" href="my.js">
  • Local javascript - <script type="text/javascript" src="my.js" async defer>
  • DNS-Prefetch of CDN domain - <link rel="dns-prefetch" href="//my.cdn.com">
  • Preconnect of remote javascript - <link rel="preconnect" href="//consentscript.tld">
  • Remote javascript - <script type="text/javascript" src="https://remote.server/my.js" async defer>
  • Inline javascript - <script>myFunc...;</script>
  • Inline styles - <style>body{color:black;}</style>

Empirically, I realized that the order of these assets, as they are listed in the HTML head, influences the loading speed of the page and the Core Web Vitals metrics.

Could somebody point me to the performance-optimized order of asset placement in the HTML head? A link to documentation would help me too.

Evgeniy
  • 2,337
  • 2
  • 28
  • 68
  • This may answer your question: https://stackoverflow.com/questions/1987065/what-are-best-practices-to-order-elements-in-head – Rendolph Oct 26 '21 at 11:49
  • On the first view is the thread you shared mostly about w3c rules than about performance. But nevertheless thank you, in parts it will be helpful. – Evgeniy Oct 26 '21 at 12:19
  • as I feared - the thread is about w3c and not about performance - not really helpful :( – Evgeniy Oct 27 '21 at 09:43

1 Answers1

2

Check out Get your head straight by Harry Roberts, summarized in this Smashing Magazine post and CSS Tricks article for guidance and tools to help you optimize the <head> contents.

Rick Viscomi
  • 8,180
  • 4
  • 35
  • 50
  • Do you probably know, Stoyan Stefanov of phpied.com offered some years ago a test tool to test performance of different orders of different assets (local and remote CSS, JS, images, and fonts) . I can't find it anymore :( – Evgeniy Oct 28 '21 at 09:39
  • No sorry I'm not sure about that tool – Rick Viscomi Oct 28 '21 at 19:52
  • if interesting - Patrick Meenan recommended a similar, pretty the same tool: https://cuzillion.com/ – Evgeniy Nov 04 '21 at 17:22