views:

381

answers:

3

Frequently, I just want to drop a bit of jQuery on an individual page. Given my early understanding of Sitefinity, I think...

  1. I can't easily put JS in the <head>.

  2. I could put JS in a Generic Content control, but then my JS is sitting inline in the <body>. Maybe I need to relax, but I don't usually like to put much JS in the <body>.

It feels like this kind of scenario is an afterthought. Is JS a 2nd-class citizen in Sitefinity?

+2  A: 

JavaScript does not live in the head. Yahoo even says it is better for performance

epascarello
+1  A: 

I agree with epascarello you really shouldn't be putting your javascript in the head anyway.

And just in case you didn't know about this the jQuery framework is part of Sitefinity. The article also shows you how you can include external libraries in sitefinity from anywhere withing your project whether it be master page or user control.

Sean Molam
+1  A: 

Why not have the jQuery code in a separate .js file and use unobtrusive JavaScript? With jQuery you can separate behavior and markup so nicely that you should never have to include JavaScript in your head or body ever again.

Just use the standard onLoad function in jQuery and put all of your initialization code in there.

Try it, I think that you will like it! If you like using CSS for separation of presentation and markup, then jQuery can do the same thing with behavior and markup.

BeaverProj