WordPress Custom Fields: Page/Post Spicific Script Includes

  • # November 1, 2009 at 4:32 pm

    After watching Chris’ screencast on WordPress custom fields ( … wordpress/) I thought about another possible use. Including a script or stylesheet on only one page or post. So I wrote a little script to grab the value of a custom field and output the proper markup to include it in the header. I posted the script and a description of what it does in a post on my website: … ton-fields. I was wondering if someone more knowledgeable could take a look at it and tell me what you think, is this a good way to do this?

    # November 3, 2009 at 12:32 pm

    Have you had the time to read through Chris’ post about his new design on his personal site?

    I think he has accomplished with his posts what you are wanting to do. Maybe I’m wrong. This may not be the exact response you were looking for, but I’m hopeful that it helps you.

    # November 3, 2009 at 2:01 pm

    You are right. The plugin he used does almost exactly what I did. I hadnt actually read that whole article yet. I will check out that plugin and thanks for the reccomendation. He is really good at doing things right when I am thinking about how to do it.

    It seems like that plugin has one distinct advantage over my script in that a page that shows multiple posts would load all of the included scripts while you could specify to only load the script in the single view of the post/page if it isnt needed. That is all good and well, but does that extra functionality come at a cost of longer load time? If all you are doing is ocasionally loading a special css or javascript file for a page/post, is the plugin worth it as opposed to this extra 15 lines of code?

    # November 3, 2009 at 4:22 pm

    I don’t know if the increased load time would be terrible noticeable if you’re using optimal coding. I haven’t used the plug-in though, maybe Chris will chime in an offer some thoughtful advice to you. Although his site doesn’t seem to suffer from much of a load time drag.

    Hope everything works out for you in the end.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.