But more look into different sites, that are managing it with some static domain, beside there OG, the more i think people are genuenly into doing it.
Most of that is probably from older websites that implemented domain sharding over five years ago. Times have changed, and domain sharding is increasingly pointless.
Domain sharding can be an effective performance optimisation for HTTP/1 connections. But even then, it's only useful if your website has a lot of HTTP requests.
If the browser is connecting via HTTP/2, then domain sharding actually harms performance slightly due to the extra DNS lookup(s).
Domain sharding is somewhat annoying to implement. You have to decide which resources go on which domain. Technically you don't have to buy a second domain, as you can use CNAME alias to "fake it".
At one point I had a setup that randomly (but consistently) assigned my static files to one of two CNAME aliases, s1.domain.com and s2.domain.com. I think I just took the last modified time of the file, and checked whether the last number was odd or even.
It made very little noticeable difference to performance, and it was complicated; so I stopped using it. It was a good example of excessive/premature optimisation.
I recommend you don't waste your efforts on this outdated approach. But if you really want to shard, use two domains (this was the recommendation from Steve Souders and Yahoo). More than two, and you start to see increasing slow down from the DNS lookups.
A more effective option would be to start using a CDN to host your static files, as this reduces latency by locating the files closer to the client. By doing this you actually end up with some domain sharding anyway, especially if you are using multiple CDNs (e.g. a general CDN for JS & CSS, plus an image-specific one like Sirv).
Using a CDN can potentially provide a dramatic performance boost for users who are located a long way from your server. Look for a CDN with HTTP/2, however.
So maybe, to add to the questions above - is this a good practice overall and should/could it be implemented in Laravel?
My answer would be:
- No, it's arguably bad practice and almost certainly not worth the hassle
- It's definitely not something that Laravel should offer as part of the framework, but you could do it yourself