Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Load JS files faster inside CGI script

by kalyanrajsista (Scribe)
on Feb 24, 2010 at 11:47 UTC ( [id://825050]=perlquestion: print w/replies, xml ) Need Help??

kalyanrajsista has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Load JS files faster inside CGI script
by Corion (Patriarch) on Feb 24, 2010 at 11:56 UTC

    I'm not really sure where your question is about Perl.

    Some general hints:

    1. 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.
    2. 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.
    3. 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.
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Load JS files faster inside CGI script
by zentara (Archbishop) on Feb 24, 2010 at 13:59 UTC
    My .js file is around 7 MB

    Now I remember why I use noscript. Isn't 7 meg getting a bit excessive for code that is just supposed to do minimal browser-side checking?


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku
Re: Load JS files faster inside CGI script
by Mr. Muskrat (Canon) on Feb 24, 2010 at 18:38 UTC

    You really should follow the advice already given but I thought that I would share a few thoughts that came to mind when I read your post.

    Split your JavaScript out into libraries so that you can only load the scripts that you need instead of sending everything every time. The browser will cache the libraries if you let it.

    Use AJAX for page updates where it makes sense, like updating a selection box when a selection is made in another selection box.

    If you are working with data and not HTML or JS snippets, then store and transmit it as JSON (JavaScript Object Notation -- you send a data structure that can be converted into a JS object). Once you have your JS object, it can be used or transformed however you like.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://825050]
Approved by keszler
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-24 05:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found