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?

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #44233
    AlirezaM
    Participant

    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 …

    #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.

    #132441
    AlirezaM
    Participant

    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)
  • The forum ‘Other’ is closed to new topics and replies.