I'm not really sure where your question is about Perl.
Some general hints:
- Benchmark to find where the bottleneck is. You're sending 7MB over the wire, which is a lot of data. Maybe split up the Javascript into smaller files that don't need to be loaded every access.
- If you're generating the Javascript from Perl, look whether you can create the Javascript as static files, thus reducing the time it takes until the answer can be sent.
- Consider eliminating the Javascript alltogether and only deliver information when it is requested instead of all information at once. This is the part where Perl is of most help I guess.