If I break up some of my longer client side code into separate includes, how much of a performance hit is that for the client?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well for starters most browsers only allow 6-8 simultaneous downloads from the same domain. So if you have 10 files to load, the first seven will load at the same time, when one completes the 8th will load and so on… This is why most sites use CDNs – so they can download more files at the same time. A best practice is to develop in separate files but during your production deployment you compile them into the same file and run minify etc… this gives you the best of both worlds.
If you insist on multiple files then look into hosting them on different domains (maybe Amazon S3 for instance, or just a subdomain off of your website) to speed up your load times. You should use no more than 5 domains for loading, though, as each domain requires a DNS lookup which can be costly. You should be hosting more than a couple files from each (sub)domain otherwise its benefit is outweighed by the DNS lookup.