I've taught myself everything I know about javascript, html, and php so I'm no expert on anything, especially best practices.
Somehow I started putting my php functions at the top of a page, my html in the middle, and my javascript at the bottom on my partial files (stuff loading via ajax). Any event listeners, etc. go into domready. I don't know if your asking what the best practice is, but it sure works for me :P. I guess it's my own crappy version of MVC. On a full page (not loaded by ajax) I put the javascript to the head. On Jan 5, 5:46 am, Michal <[email protected]> wrote: > FUC?? I think maybe I'm not that good with those internet acronyms.... > > On Jan 5, 12:32 pm, keif <[email protected]> wrote: > > > > > With putting scripts at the bottom, it's been more of a "YMMV" > > approach - I can't find the yahoo article, but it's been discussed > > more than once that many people say "put it in the footer" when it's > > not a practice they follow themselves because of certain issues (one > > thing I've noticed, loading all JS in the footer causes FUC > > sometimes). > > > -keif > > > On Jan 5, 5:38 am, Nicolas Trani <[email protected]> wrote: > > > > Hi, > > > > @Michal : > > > Putting scripts at bottom speed up your page loading, i suggest you to > > > read this :http://developer.yahoo.com/performance/rules.html#js_bottom > > > > @Wanlee : > > > I suggest you to continue to use domready anyway. > > > > Maye be you can post a page to show your code? > > > > Regards. > > > > Michal a écrit : > > > > > Are you saying that 'domready' fires too early, before the html is > > > > ready? This sounds strange. It could be: > > > > > - A bug with domready. I suspect this is unlikely as this is so > > > > heavily used and tested. But if you can construct a testcase, post a > > > > bug in lighthouse. > > > > - A bug with your code somewhere: are you sure everything that > > > > accesses the DOM is inside a domready listener? > > > > > I have seen advice somewhere on the internet that says you should put > > > > Javascript at the bottom of the html, but it's never quite sat well > > > > with me, it seems a bit hackish, but I don't quite know why. I always > > > > put it in the head, with a domready. Maybe others have other > > > > suggestions... > > > > > There is the 'load' event, that waits for all images to load as well, > > > > you could try that, but I suspect that there is something else afoot. > > > > > Can you post a link to the page you're talking about? > > > > > Michal. > > > > > On Jan 5, 8:32 am, wanlee <[email protected]> wrote: > > > > >> I'm writing a few functions for sliders and json requests and it > > > >> appears that the javascript is loading faster than the html causing > > > >> the slider to not initialize. it doesn't happen on every page load but > > > >> more so in safari. > > > > >> moving my script tags to the bottom of the html solves the problem. is > > > >> this normal or could there be something wrong with my code? should i > > > >> use something other than 'domready'? > > > > >> take swing! > > > > -- > > > Nicolas Trani - web engineer > > > Weelya - Improve the web > > > 32 rue du faubourg boutonnet > > > 34090 Montpellier > > > Tel/Fax : 04 67 169 778http://www.weelya.com > > > > Notre agence sera fermée du 12 au 16 janvier 2009
