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

Home Forums JavaScript Idea: Putting all javascripts into one script

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #170020

    I am working on a website that has lots of features which my boss wants. The problem as you can imagine that, I have this problem:

    “Render-blocking JavaScript and CSS in above-the-fold content”

    So got me thinking, if there was a way to create a plugin that will grab all those scripts and make them into one, so it reads only one script. May be there is already one I am not aware of.



    A Plug-in?

    Doubtful…but you can do it manually…and most of us do.


    Grunt or Gulp, both are task runners and can concatenate blocks of scripts or styles. Also you might consider placing your JS files before the closing </body> tag instead of in the <head> if that’s where they currently are.


    Part of what TheDoc is alluding to, and a motivation for not concatenating large 3rd party libraries, is caching and code volatility. It’s likely that larger 3rd party libraries will be updated less frequently so it makes sense to leave them separate in order to leverage caching better on those files. It’s also likely, but not guaranteed, that the other custom scripts in your page may change more frequently (due to updates, etc.) and therefore will need to be cache-busted more regularly. Separating code by how frequently it may change is a smart technique that allows your site to be better optimized when served to the user.


    @dyr true, on my latest project i am actually using cookies.js and have placed my (some combined js) and other js before </body> and making cookies of most JS and CSS which are unlikely to change


    If you’re working with a WordPress site (looking at your avatar, you might), you can use the W3 Total Cache plugin, which consolidates and minifies all your Javascript files into 1 large JS file, and does the same with CSS.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.