[Javascript] Javascript include problem?

Jason Pruim lists at pruimphotography.com
Sat Oct 2 15:20:59 CDT 2010


On Oct 2, 2010, at 3:55 PM, Mike Dougherty wrote:

> On Sat, Oct 2, 2010 at 11:45 AM, Jason Pruim <lists at pruimphotography.com 
> >wrote:
>
>> I'll start changing all my stuff to use the external script  
>> commands then
>> :) But with the caching... Would it store all the variables as  
>> well? What
>> the whole page is doing is simply displaying a google map of a  
>> point that is
>> retrieved from my database... So caching isn't necessarily what I'm  
>> looking
>> for... Unless it would refresh the variable with the ID number but  
>> store the
>> rest of the script...
>>
>> You also said it worked? What browser are you using and what page  
>> are you
>> visiting? :) I'm still fighting with it hehehe :)
>>
>>
> "worked" is open to interpretation I guess - I didn't see any errors  
> or
> particular ugliness.  I have no idea how much of what I'm not seeing  
> is
> broken vs. not-yet-implemented.  I guess I gave large benefit of the  
> doubt
> :)

The site is nearly done... Just need to polish it a little bit and get  
the map working! :)
>
> when you ask "would it store my variables" - are you sure your  
> declarations
> are 'variable' if they're hardcoded in a file now?

The way the site is working right now (All done from examples I've  
found on the net so it may not be the best way...)

The file that is referenced in the GDownloadURL grabs the info from  
the database and puts it into an XML format which is then passed into  
the javascript to process the XML and plot it out on the map. The map  
should be displaying a single point on the map centered over that  
point along with the address below it and brief info about the event.

All of that is working perfectly fine as long as the html/javascript  
is in the same page AND not included in my final display page... Once  
I try and include it all I get is a grey box along with the google  
buttons...


>
> Typically you would have let's call it 8-10k worth of function  
> definitions
> and other program code to make your page work.  If you have less  
> than 1k
> worth of data that changes frequently compared to the program code,  
> for
> example: weather details, then consider:  Put the program code in  
> one script
> file and the data in another file.  Reference both in your markup.   
> The
> browser will request the program code effectively, "Hey, has the  
> file I
> downloaded last week with X timestamp+bytecount still fresh?"  If  
> the server
> says, "Yup, that's what I'd serve up: use it" then you save the time  
> it
> takes to download 8-10k worth of code the browser already has.  Then  
> the
> browser says, "What about this data file I have from 5 days ago?"   
> and the
> server responds, "No I update this file hourly, here's the 1k of new  
> data"
> Instead of downloading markup(4k)+program(10k)+data(1k)=15k, you  
> download
> markup(4k)+program(cached)+data(1k)=5k and your page is ready 66%  
> quicker.

really? That much extra? Wow... Javascript will take some getting used  
to :)
>
> If it sounds like I'm just being a kook about a few bytes, download  
> the
> YSlow extension to Firebug (in Firefox) and examine the page weights  
> of
> "unprimed cache" vs "primed cache"  and qualitatively feel the  
> difference
> between a content-rich page like cnn.com on first-download and  
> subsequent
> requests.  (1141.4K vs 109.4K)
>
> The takeaway (if there is one) is that you build for performance  
> from day 1
> - high performance is not something you can add-on at the end of a  
> project
> when you find that it's too slow/clunky for anyone to tolerate.  I  
> would
> also preemptively counter the "Oh this is just a small project I'm  
> doing for
> fun, so it doesn't really matter"  with the suggestion that small/fun
> projects are how you learn to do things the proper way - so when you  
> get the
> large project you already have good habits/skills.  Then of course the
> project manager/boss will push you to cut corners for the sake of  
> time/money
> budgets  :)

The nice thing about being a freelancer is I'm the boss :) So I'll  
just build extra time into the quotes if I decide to keep pursuing my  
venture into Javascript... Which I most likely will... I'm very  
intrigued by it, but it's a BIG jump from PHP which is where most of  
my knowledge comes from.

Thanks again! :)





More information about the Javascript mailing list