Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^2: Load JS files faster inside CGI script

by kalyanrajsista (Scribe)
on Feb 24, 2010 at 12:08 UTC ( #825057=note: print w/replies, xml ) Need Help??

in reply to Re: Load JS files faster inside CGI script
in thread Load JS files faster inside CGI script


I do agree with all your suggestions. But, here is what exactly I'm doing

~ I've a 2 dropdown list where data in second list box is to be displa +yed without actually loading the page. ~ To achieve that task, I've created my JS file with data before hand +and loading during onChange() event ~ My JS file contains a simple function along with data ( I'll mention + in below step what exactly is the data) which returns Options based +on the selection of first dropdown list ~ Data in JS is actually Hash of Arrays which piled up aroud 7MB

How should I proceed. Is there any way I can minimize any of the steps so that my JS file size cannot pile up

Replies are listed 'Best First'.
Re^3: Load JS files faster inside CGI script
by Corion (Pope) on Feb 24, 2010 at 12:13 UTC

    That's easy. Don't send the whole data, but request the data from Javascript when the user makes the first selection. For example the jQuery framework makes it really easy to request data without reloading the complete page. On the Perl side, you have a script that returns the options for the current selection.

      any working example, Please

        I'm sorry, but this is not a code writing service. This is a site for people who want to discuss Perl problems or programming problems and their application in Perl. This is not a site where people write code for you, especially without specifications.

        Your problem and question seem ill thought out, as you haven't made any effort to determine the cause of the load nor have you described any of your attempts to reduce the current bottleneck. Also, you haven't drawn any connection from your problem and how it relates to Perl. I recommend that you spend some time analyzing where the problem is, then some time analyzing how you can leverage existing tools like Perl and jQuery to solve your problem, then implement one or more solutions using these tools, and then, if you still have problems, ask again, this time showing representative input, output and code.

        Check out - you can tell jQuery to go to a URL to validate a field (almost) automatically. This would make a dramatic difference in your performance, as that 7MB would never have to leave the server. (You can always leverage Spidermonkey to run your current validation JS on the server if need be, but unless it's hideously complex I'd redo it in Perl.)

        A quick Google search on 'jquery remote validation' turned this right up.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://825057]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2018-06-24 03:13 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.