The simplest way to change were the JavaScript includes are added is to
create your own version of sfCommonFilterthe content of which would be as
follows this will allow you to continue to use the view.yml to control the
css / javascript files but they will be placed in a more optimized location.
I did submit this as a proposed upgrade some months ago but it was never
implimented...
// execute next filter
$filterChain->execute();
// execute this filter only once
$response = $this->context->getResponse();
sfLoader::loadHelpers(array('Tag', 'Asset'));
// include stylesheets
$content = $response->getContent();
if (false !== ($headPos = strpos($content, '</head>')))
{
$cssHtml = '';
if (!$response->getParameter('stylesheets_included', false,
'symfony/view/asset'))
{
$cssHtml = get_stylesheets($response);
}
// Place the CSS tags before the closing </head> tag
if ($cssHtml)
{
$response->setContent(substr($content, 0, $headPos).$cssHtml.substr(
$content, $headPos));
}
}
// include javascripts
$content = $response->getContent();
if (false !== ($bodyPos = strpos($content, '</body>')))
{
$jsHtml = '';
if (!$response->getParameter('javascripts_included', false,
'symfony/view/asset'))
{
$jsHtml = get_javascripts($response);
}
// Place the JS tags before the closing </body> tag
if ($jsHtml)
{
$response->setContent(substr($content, 0, $bodyPos).$jsHtml.substr(
$content, $bodyPos));
}
}
$response->setParameter('javascripts_included', false,
'symfony/view/asset');
$response->setParameter('stylesheets_included', false,
'symfony/view/asset');
Regards
Alistair
On 25/03/2008, Kris Wallsmith <[EMAIL PROTECTED]> wrote:
>
>
> I just performed this optimization on one of my sites. It's as simple
> as adding a call to the helper function include_javascripts() at the
> bottom of your layout file(s). The common filter will know you've
> already placed your Javascript includes and will only add stylesheets
> to the <head> section.
>
>
> Kris
>
>
> On Mar 25, 9:23 am, Marijn <[EMAIL PROTECTED]> wrote:
> > So I could just add some PHP code in a partial that would be included
> > on the bottom of every template. The parial would first call
> > get_javascripts and then delete all javascripts from the sfResponse
> > object..?
> >
> > Thanks for your quick reply.
> >
> > Marijn
> >
> > On Mar 25, 4:56 pm, Robert Speer <[EMAIL PROTECTED]> wrote:> try
> get_javascripts ()
> >
> > > the api is easiest to search here:http://www.gotapi.com/symfony
> >
> > > On Mar 25, 10:18 am, Marijn <[EMAIL PROTECTED]> wrote:
> >
> > > > Hi everybody,
> >
> > > > I think this is question belongs in the developer list, if not
> please
> > > > be kind enough to tell me ;-)
> >
> > > > Currently Symfony adds javascripts in the head tag of the page but I
> > > > prefer to put them on the bottom of the page for faster rendering
> > > > content on the page. For more information about that you can check
> out
> > > > this link from Yahoo on front-end
> optimizationhttp://developer.yahoo.com/performance/rules.html#js_bottom(pretty
> > > > useful I'd say).
> >
> > > > Is this something that can be considered as an option within symfony
> > > > or do I need to hack my way through this. If so where to start..? A
> > > > quick peek at the source didn't result in to much insight on the
> > > > addJavascript function.
> >
> > > > Thanks,
> >
> > > > Marijn
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---