Using CFIF in default layout to include javascript

44 views
Skip to first unread message

Randy Johnson

unread,
Dec 6, 2009, 3:16:43 PM12/6/09
to ColdFusion on Wheels
Is it considered good practice to use CFIF's in the default layout?  

For example. on my edit profile page I need to include special javascript that isn't used on other pages.


Thanks!

Randy

John C. Bland II

unread,
Dec 6, 2009, 3:24:56 PM12/6/09
to cfwh...@googlegroups.com
In general I'd say, why not?

I would put a cfparam at the top defaulting to false then set that var in the specific controller action.

---
John C. Bland II
http://www.johncblandii.com
http://www.johnandseason.com
http://www.twitter.com/johncblandii
---
Suggested sites:
http://www.lifthimhigh.com - "Christian Products for Those Bold Enough to Wear Them"
http://www.sportsmatchmaker.com - "What are you doing today?"


--

You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.

Russ Johnson

unread,
Dec 6, 2009, 7:05:54 PM12/6/09
to cfwh...@googlegroups.com
What I would do is make use of a really handy tag called cfhtmlhead. 

In the action that you want the js file to be included on, I would just pull the call to the js file in the cfhtmlhead tag and cf will put it in the head for you. That will eliminate the conditional from being run on every request in your layout.

- Russ

m...@iamjamesgibson.com

unread,
Dec 6, 2009, 7:49:00 PM12/6/09
to ColdFusion on Wheels
Hey Randy,

If you have a lot of javascript on your site it might be good to try
out the asset bundler plugin. You can compress and bundle all of your
js and css together to have a single download of all of the js for the
site. This is the preferred method for js/css since once it is
downloaded by the client the first time, it is cached and there will
be no performance penalty. I have been using the plugin for our
application and am able to compress over a 1.8MB of javascript (over
40 files) into 600k. This also allows me to keep my js / css neat and
organized into many smaller files and know that I will not have the
http performance penalty.

http://cfwheels.org/plugins/listing/4

James

On Dec 6, 7:05 pm, Russ Johnson <russ.cfco...@gmail.com> wrote:
> What I would do is make use of a really handy tag called cfhtmlhead.
>
> In the action that you want the js file to be included on, I would just pull the call to the js file in the cfhtmlhead tag and cf will put it in the head for you. That will eliminate the conditional from being run on every request in your layout.
>
> - Russ
>
> On Dec 6, 2009, at 3:24 PM, John C. Bland II wrote:
>
> > In general I'd say, why not?
>
> > I would put a cfparam at the top defaulting to false then set that var in the specific controller action.
>
> > ---
> > John C. Bland II
> >http://www.johncblandii.com
> >http://www.johnandseason.com
> >http://www.twitter.com/johncblandii
> > ---
> > Suggested sites:
> >http://www.lifthimhigh.com- "Christian Products for Those Bold Enough to Wear Them"
> >http://www.sportsmatchmaker.com- "What are you doing today?"
>
> > On Sun, Dec 6, 2009 at 2:16 PM, Randy Johnson <rjohnso...@gmail.com> wrote:
> > Is it considered good practice to use CFIF's in the default layout?  
>
> > For example. on my edit profile page I need to include special javascript that isn't used on other pages.
>
> > Thanks!
>
> > Randy
>
> > --
>
> > You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
> > To post to this group, send email to cfwh...@googlegroups.com.
> > To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/cfwheels?hl=en.

John C. Bland II

unread,
Dec 6, 2009, 8:29:10 PM12/6/09
to cfwh...@googlegroups.com
Nice. I forgot about that tag (and never use it). lol

---
John C. Bland II
http://www.johncblandii.com
http://www.johnandseason.com
http://www.twitter.com/johncblandii
---
Suggested sites:
http://www.lifthimhigh.com - "Christian Products for Those Bold Enough to Wear Them"
http://www.sportsmatchmaker.com - "What are you doing today?"


tpet...@gmail.com

unread,
Dec 6, 2009, 10:32:57 PM12/6/09
to ColdFusion on Wheels
if i'm not mistaken, per added the head argument to both the
javaScriptIncludeTag and styleSheetLinkTag which does what you want.
this code is in edge though.

On Dec 6, 8:29 pm, "John C. Bland II" <johncblan...@gmail.com> wrote:
> Nice. I forgot about that tag (and never use it). lol
>
> ---
> John C. Bland IIhttp://www.johncblandii.comhttp://www.johnandseason.comhttp://www.twitter.com/johncblandii
> ---
> Suggested sites:http://www.lifthimhigh.com- "Christian Products for Those Bold Enough to
> Wear Them"http://www.sportsmatchmaker.com- "What are you doing today?"
>
> On Sun, Dec 6, 2009 at 6:05 PM, Russ Johnson <russ.cfco...@gmail.com> wrote:
> > What I would do is make use of a really handy tag called cfhtmlhead.
>
> > In the action that you want the js file to be included on, I would just
> > pull the call to the js file in the cfhtmlhead tag and cf will put it in the
> > head for you. That will eliminate the conditional from being run on every
> > request in your layout.
>
> > - Russ
>
> > On Dec 6, 2009, at 3:24 PM, John C. Bland II wrote:
>
> > In general I'd say, why not?
>
> > I would put a cfparam at the top defaulting to false then set that var in
> > the specific controller action.
>
> > ---
> > John C. Bland II
> >http://www.johncblandii.com
> >http://www.johnandseason.com
> >http://www.twitter.com/johncblandii
> > ---
> > Suggested sites:
> >http://www.lifthimhigh.com- "Christian Products for Those Bold Enough to
> > Wear Them"
> >http://www.sportsmatchmaker.com- "What are you doing today?"
>
> > On Sun, Dec 6, 2009 at 2:16 PM, Randy Johnson <rjohnso...@gmail.com>wrote:
>
> >> Is it considered good practice to use CFIF's in the default layout?
>
> >> For example. on my edit profile page I need to include special javascript
> >> that isn't used on other pages.
>
> >> Thanks!
>
> >> Randy
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "ColdFusion on Wheels" group.
> >> To post to this group, send email to cfwh...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> cfwheels+u...@googlegroups.com<cfwheels%2Bunsu...@googlegroups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/cfwheels?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "ColdFusion on Wheels" group.
> > To post to this group, send email to cfwh...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > cfwheels+u...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/cfwheels?hl=en.
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "ColdFusion on Wheels" group.
> > To post to this group, send email to cfwh...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > cfwheels+u...@googlegroups.com<cfwheels%2Bunsu...@googlegroups.com>
> > .

raulriera

unread,
Dec 6, 2009, 11:01:31 PM12/6/09
to ColdFusion on Wheels
Really? that is cool

On Dec 6, 11:32 pm, "tpetru...@gmail.com" <tpetru...@gmail.com> wrote:
> if i'm not mistaken, per added the head argument to both the
> javaScriptIncludeTag and styleSheetLinkTag which does what you want.
> this code is in edge though.
>
> On Dec 6, 8:29 pm, "John C. Bland II" <johncblan...@gmail.com> wrote:
>
>
>
> > Nice. I forgot about that tag (and never use it). lol
>
> > ---
> > John C. Bland IIhttp://www.johncblandii.comhttp://www.johnandseason.comhttp://www.twi...
> > >> cfwheels+u...@googlegroups.com<cfwheels%2Bunsubscribe@googlegroups.c om>
> > >> .
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/cfwheels?hl=en.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "ColdFusion on Wheels" group.
> > > To post to this group, send email to cfwh...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > cfwheels+u...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/cfwheels?hl=en.
>
> > >  --
> > > You received this message because you are subscribed to the Google Groups
> > > "ColdFusion on Wheels" group.
> > > To post to this group, send email to cfwh...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > cfwheels+u...@googlegroups.com<cfwheels%2Bunsubscribe@googlegroups.c om>

Chris Peters

unread,
Dec 7, 2009, 5:42:38 AM12/7/09
to cfwh...@googlegroups.com
Nice. How does that work? Do you just pass it a value of `true`?
Reply all
Reply to author
Forward
0 new messages