Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other How to reduce number of http requests? Re: How to reduce number of http requests?

#132384
Alen
Participant

Yes. You need a build process. After you have completed your project you take all of your assets (JavaScript, CSS and Images), and you concatenate, minify and compress.

What you will end up with is only one JavaScript and CSS file so browser doesn’t have to make multiple requests to the server. The order in which the files are concatenated matters.

You can also conditionally load assets, so if you’re using WordPress:

if (is_page(‘gallery’)){
// code to load the asset
}

this way you request the asset only when it is needed.

You could have apache do this work for you with .htaccess file. See section [File concatenation](https://github.com/h5bp/html5-boilerplate/blob/master/.htaccess) line #509 from HTML5Boilerplate .htaccess file.