Enabling jQuery plugins per post vs. site

Apr 9, 2009 at 12:42 PM
I've enabled the Slimbox 2 jQuery plugin on my blog by editing /Skins/<myskin>/Views/Shared/HeadCustomContents.ascx to include the relevant javascript and css.

I now have slimbox available on every page of the site, but don't think this is a good thing. It seems unncessary to download this script on every page.

Is it possible to have the plugins loaded per post, i.e. if a post uses it it is loaded, otherwise not. Where would I make the change?

I'm also unsure how this would work on for example the homepage where a post may contain the library or not. If a picture is clicked in the main page the plugin wouldn't be available.

Thank you
Leon
Coordinator
Apr 9, 2009 at 3:26 PM
You could skin individual pages like the post item page (would be /Skins/<myskin>/Views/Post/Item.aspx) and add the script to the Scripts content placeholder along with base.js. If you might have images showing up in the post list pages (like the home page) then you could do the same to all of the Post/List*.aspx pages - and if you want the same behavior on "pages" then do the same to Page/Item.aspx.

Another benefit of using the Scripts content placeholder is that it will drop the JavaScript referenced down into the bottom of the page instead of the head so your content can render before any extra scripts are loaded up and executed.
Apr 10, 2009 at 7:03 AM
Thanks skewed, this sounds like a much better way of doing it.

L
Apr 12, 2009 at 3:57 PM
I was about to be rather redundant by starting a new thread. :-)
Lucky. I've been sifting the webs for a lightbox that will play MOVs and is jQuery compatible and I also found something http://www.shadowbox-js.com/.
It's just swell... also, I merely placed the script tags etc in the body of my post - it didm't fuss, nor did I. ^.^