Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is there a way to achieve the same effect while keeping scripts in the <head>? (Not saying that's the best idea, just wondering.)


You could have your scripts just define functions, then call all those functions from the bottom of your <body>.

Or, using jQuery, you could probably define a custom event on the <body>, that you trigger manually from the bottom of your <body>, and have your scripts in the <head> listen for that event. I've never actually tried this, though.


YUI can poll for elements to become available, with a few workarounds for browser bugs; see http://yuilibrary.com/yui/docs/event/domready.html. I think you have to roll your own in jQuery.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: