Style sheets (js, css) in subdomain or in a folder within the application?

0

I have a question. I think someone has been through it sometime, too.

I've always loaded my styles into a folder in my application:

Ex: http://meudominio.com.br/assets/css - ou js e etc

Looking at many source code from other developers, 50% use subdomain:

Ex: http://assets.meudominio.com.br/css - ou js e etc

Have some kind of subdomain for styles increase performance relative to page load?

What is the best practice for performance ?

Remembering that I use PHP with Codeigniter in most of my applications. And I have a cloud server with cpanel. (If this information helps ..)

    
asked by anonymous 18.11.2016 / 14:55

2 answers

2

Subdomain is the best option to put your static files.

Because when the user accesses it it will download the subdomain files in parallel. This will make it faster if compared to everything being on the same domain, where you will send a request, wait for the return, then start another request.

Using CDN for your files is also a good option, for example jquery, if you use jquery link and the user has already accessed some website, where he uses this CDN too, he will already have this file in the browser cache, and will not download again, which will make access to your site more fast.

    
18.11.2016 / 15:45
1

Probably because of caching and bandwidth savings.

Because if you access:

  • link
  • link
  • When accessing # 1 it will load the js, css files. If you access # 2 it will try to load again because you will find it to be a different file.

    Already using only a sub-domain both makes the site address you are if it has already loaded once it will not try to download again and will take advantage of the cache. This is why people use CDN, since several sites share the same address for a particular file eg jQuery.

        
    18.11.2016 / 15:02