The best way to merge JS files throughout the site

I have a website that has pages 1,2,3 and js files A, B, C, D, E, X and Y. The following are the files that each page contains:

Page 1: A
Page 2: A, B, C, D, E
Page 3, A, B, C, X, Y

Currently, all these files are sent separately, and it takes some time to download them for the first time. I know that compressing them into a single file reduces the transfer time, so this is my plan. But in this case, I do not want to condense them all into one file, because page 3 can benefit from page 2, already having cached A, B and C (which would be impossible if there was a large ABCDE file and a large ABCXY file) . And yes, users will switch between 2 and 3 in typical use.

But the answer is not needed here, just “create an ABC file, a DE file and an XY file and do it” because the situation I described is only part of a more serious problem.

How do people usually deal with combining JS files on a website where some pages use some files?

Note1: all files have an order from several hundred to several thousand lines.

Note. If you cannot answer the question due to the absence of any details, explain why this detail is important, and then how it can change your answer!

+5
source share
2 answers

, javascript, ? ; , ?

: javascript, , .

+1

, , . :

Page 1: A
Page 2: ABC, DE
Page 3: ABC, XY

, , ABCDE, HTTP-, ( script ), , . - !

: 2 script ( ), . , .

, . Java Jawr, , , - .

ADD-ON: , Jawr "", , , . jawr.debug.on = false .

, :

Page 1: A
Page 2: A, B, C, D, E
Page 3: A, B, C, X, Y

ABC... jawr imho, . java, , , /.

0

All Articles