Support Forums

One css / js file for two domains

I have a css and a js file for two domains. What is the best solution that will allow to minify the files?
Just copy the files to the other domain after changing?
Or is there a better solution that would link the file to both domains?

Thanks in advance!

You can host the CSS and JS files on one website and link to that website from the other websites.

Thanks, hrishikesh!

I have done that and it works. But netlify only seems to minify the files on the same domain.

I could use an external minifyer for the external domain. But an automatic solution would be nicer.

Can I link the minified cloudfront.net file or does that address change?

Any ideas or suggestions?
I would appreciate that.

Yeah, you could enable post processing for the assets website that you create, but the Cluoudfront address would be dynamically generated.

So, you’d have to build that website first, let it successfully deploy, then take a links from that website and add I to your other websites.

Do note that, according to the Terms Of Service, you’re not allowed to use Netlify only as a remote storage solution. So, as long as you’re requesting the scripts from your Netlify websites, it is okay, not otherwise.

Thanks, hrishikesh!
All are netlify sites - so no problem.