1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Rep Power

    Opening a pipe between Javascript and Perl


    I use JavaScript arrays to store the dynamic data of my SVG template. These dynamic variables store colors, which are used to shade a map and thereby show a statistic graphically. A version of this document, in post template form, is viewable here - http://baz.perlmonk.org/r.cgi?name=Griffin&=.svg
    The size of this doc is about 80K, and takes a while to download (I have a 56K connection); SVG is also new so there are some peculiarities during the download of this file to the client. I'm simply wondering if it would be possible to open a pipe between Perl and JavaScript, so that when the user requests a new Statistic set, only the colors are downloaded (these would fill the color array), there is nothing else that would need re-downloading.

    I have read a bit about caching before, and I think that perhaps it could be done this way too. Is it possible to store the JavaScript section of a SVG doc in a separate file? If so, I could perhaps set the expires-date for some time into the future for the SVG doc, and for sometime in the past for the JavaScript doc. That way only the JavaScript would be re-download. Now that I think of it, the JavaScript is also large - but most of it is static. Is it possible to have two JavaScript files?

    Anyway, I hope I made some sense,



  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Sacramento, CA
    Rep Power
    I can think of two options.

    First, you use a hidden frame to load your javascript, then call a function that gets the values from the hidden frame so that you can use them in your script. Asking for a new Statistics set would cause the hidden frame to open a new page and the function to run.

    Second, you could create a unique .js file for each user that visits the page. Something like colors2002-08-26-21-08-42602284.js that contains your color array. Subsequent requests to the script by the same user cause this file to be overwritten with the new color data, then you need some sort of garbage collection to delete the file after an hour or so.

    I'm thinking the first option is probably simpler But I don't know how your system is setup, so maybe not.

    And no, you can't open a pipe between them. Javascript can't make http requests by itself, it has to ask the browser to make them (hence the hidden frame).

IMN logo majestic logo threadwatch logo seochat tools logo