[thelist] [JavaScript] event listeners and overhead question

Tom Dell'Aringa pixelmech at yahoo.com
Tue Feb 21 10:09:19 CST 2006

Hi folks,

I'm using Matt's event listener and addBodyOnload function over at:


(Thanks Matt!) It works great. I have a fair amount of event handline being done locally that I'd
like to remove from the page and do it unobtrusively, like some buttons that adjust a price total
on a page when selected/deselected. 

Out of the total app, these pages account for 2 pages out of say 40. I could do this:

function addAdjustPricing()
  //code that finds the appropriate button and attaches the onclick event.

Then add it to onload like so:


So I would have removed the local code out of the HTML which is a Good Thing. I probably have a
good 4-6 more instances of the same thing going on that I could remove locally and attach to the
onload event in my main script.

So, finally the question is - does it make sense to do this 'globally' with the event handlers
which will now run and check for such things every page - does this add unneccesary processing?

Or, can I add the addBodyOnload(addAdjustPricing) at the top of the local pages? That seems like
something I'd want to avoid. I'm fairly sure what I want to do is okay, I just want to make sure
I'm not heading down the wrong path.




Professor Rumford: 'But I still don't understand about hyperspace.' 
The Doctor: 'Well, who does?' 
K9: 'I do.' 
Doctor: 'Shut up, K9!' 

More information about the thelist mailing list