Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
javascript, css, or other head elements "lower" in the page
I’ve just begun using yslow for firebug and one of the things it suggests is that I might put some of my JS files, like my jquery file lower in the page. I assume this is suggesting this so that it loads last. What is the protocol for something like this?
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
Re: javascript, css, or other head elements "lower" in the page
I always put JS files external to the site near the end of the page, like the code for Google Analytics, so your page render is not held up by another server’s hiccups. But if the JS file is being called from the same server, like jquery.js, I don’t see why it can’t be called from the head. On a multi-page visit, it’s going to get cached no matter where it is located on the page.
TextPattern user since 04/04/04
Offline
Re: javascript, css, or other head elements "lower" in the page
Per W3C standard, script elements are allowed anywhere in the page, be it inside of the <head>
or the <body>
element – it is both valid. It’s a kind of urban legend that all scripts should go into the <head>
. The only thing you’ve go to keep in mind that all scripts have to be loaded prior to their first use. Which somehow limits your freedom to relocate them from attic into basement.
Last edited by wet (2007-07-30 15:43:21)
Offline
Re: javascript, css, or other head elements "lower" in the page
Thanks fellas. Very useful info.
I sound like sir tophum hat. “You’re a really useful engine!” :)
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
Re: javascript, css, or other head elements "lower" in the page
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: javascript, css, or other head elements "lower" in the page
Pat64,
the yslow article above actually covers those things and more in stronger detail, but thanks for thinking to post it.
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline