Grow your CSS skills. Land your dream job.

How to reduce number of http requests?

  • # April 18, 2013 at 8:34 pm

    Hello!

    I have used about 24 js plugins inside of my pages and when I use a speed optimization system it gives me a high http request error.

    How can I decrease this number?

    Is it good to put all of js codes inside of only one file?

    notice I’m using jquery , jquery ui , jqury cookie and …

    # April 19, 2013 at 12:02 am

    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.

    # April 19, 2013 at 10:53 am

    Thank you @AlenAbdula !
    I’m now working on html version of my template.
    How should I do this work for html?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".