optimizationpreloadpreconnect

Is there any benefit in using <link rel="preload"> or <link rel="preconnect"> for resources on the same domain as the original page?


I've been reading up on performance benefits of using and to help fetch critical resources but one thing I can't quite figure out is whether these techniques still offer benefit when the resource is located on the same domain as the page that's requesting them.

E.g. I'm optimizing a page at abc.com Should I add a <link rel="preconnect" href="abc.com"> or <link rel="preload" as="script" href="abc.com/main.js"> to my markup? Or will it not have any effect since the current page is on the same domain as the link href values?


Solution

  • preconnect will have no effect (you are already connected to the domain).

    preload will have an effect (causing resource to be fetched immediately, without waiting to discover where in the page is it used).