How the comparison is computed
The alignment uses Myers' algorithm, which is the same one git diff uses by default. Its useful property is that the cost scales with how different the two inputs are rather than how large they are, so two nearly identical thousand-line files are aligned almost instantly. The common prefix and suffix are stripped before the algorithm runs, which reduces a one-line change in a long file to a one-line problem.
The alternative, the textbook dynamic-programming table, would need twenty-five million cells for two five-thousand-line files. That is both slow and roughly a hundred megabytes of memory, in a browser tab, for a diff.