- This topic is empty.
May 13, 2014 at 8:03 am #170020mevaserParticipant
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:
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.
Cheers,May 13, 2014 at 8:04 am #170021Paulie_DMember
Doubtful…but you can do it manually…and most of us do.May 13, 2014 at 8:22 am #170024dyrParticipant
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.May 13, 2014 at 1:11 pm #170060dyrParticipant
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.May 13, 2014 at 1:36 pm #170063RohithzrParticipant
@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 changeMay 14, 2014 at 3:42 am #170161SenffParticipant