Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-07-30 13:23:55

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

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?


Offline

#2 2007-07-30 15:40:31

reid
Member
From: Atlanta, Ga.
Registered: 2004-04-04
Posts: 224
Website

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

#3 2007-07-30 15:41:41

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

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

#4 2007-07-30 15:47:21

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

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!” :)


Offline

#5 2007-07-31 07:32:51

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,634
GitHub Twitter

Re: javascript, css, or other head elements "lower" in the page

Matthew,

I think this article can be helpfull : on cssbased.com website

Cheers,


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#6 2007-07-31 12:20:56

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

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.


Offline

Board footer

Powered by FluxBB