Hey all, Two quick questions for you. I couldn't find the answers while searching... This would be a great thing to add to the jQuery FAQ, by the way.
(1) Is it advisable to place a page's $(document).ready() stuff in an external .js file? I've been doing a lot of reading and research on optimizing my front end code, and YSlow seems to make a big deal of placing code externally if possible for caching reasons. I understand the usefulness of placing the code in an external document for that reason, however, the problem is that there are a lot of functions for button and link clicks, shows/hides, etc., that are unique to that page and used differently on other pages. Thus, putting it externally means it would most likely have to be in an independent file just for that page... which means an added HTTP request which is really the speed killer. So anyways, looking for thoughts on this one. (2) Is it advisable to place the $(document).ready() at the bottom of the page right before the closing BODY tag? Also when doing my research, I've seen that YSlow makes a big deal of this as well. I'm sure many of you on here have discussed it or thought about it yourself. My question though is does it make sense to put the ready() code at the bottom? Does it help? Is it useful? Will it break? Thanks in advance for any feedback. Take care everyone.