Unfortunately, how javascript is included does matter. If you are running any javascript on load (such as an ajax action to grab content) then the function call needs to be after the methods that support the function is defined (such as the prototype and scriptaculous libraries). To do this easily you need to adopt at least part of the Unobtrusive Javascript methodologies.
The perceived performance implication can be significant. Content after a script is not progressively rendered until the script is loaded, so if you reference 7 javascript files (Prototype+Scriptaculous) in the Head, nothing will be rendered until all the script files are loaded. This can be particularly pernicious since browsers follow the recommendation that they only download two objects per domain at a time. So even if your server is responding very fast -- the perceived performance is only as good as the client's ability to fully download all script files declared before the displayed content. jbw On 9/1/07, Fabian Lange <[EMAIL PROTECTED]> wrote: > > Hi, > I like that. Unfortunately, like always when it comes to changes, I would > propose to make this "configurable" :) But generally, I think that is even a > compatible solution. At the moment the javascript is in head, so it is quite > unlikely that the position of the javascript matters, as long as the > javascripts are not outputting meta or css information via document write > (which is quite unlikely). > Nice Patch and good proposal for 1.1 > .: Fabian > > -----Original Message----- > From: > [EMAIL PROTECTED] > om > [mailto:[EMAIL PROTECTED] > groups.com] On Behalf Of [EMAIL PROTECTED] > Sent: Freitag, 31. August 2007 23:29 > To: symfony developers > Subject: [symfony-devs] Optimization > > > Lots of people are looking at ways to optimize symfony but one simple > way that seems to have been over looked is a method described in the > following article: > > http://developer.yahoo.com/performance/rules.html > > In the article the writer describes the benefits of including css in > the head of the html and all js before the closing body tag. > > I'm not sure peoples thoughts on this? I understand that it is > perfectly possible to write your own sfCommonFilter.class.php that > will move the location of the includes. But I do feel that this is a > very simple modification that will improve the page rendering > especially if developers also combine and minify their css and jss > files. > > Here is my suggested modifications to the sfCommonFilter.class.php > > <?php > > /* > * This file is part of the symfony package. > * (c) 2004-2006 Fabien Potencier <[EMAIL PROTECTED] > project.com> > * > * For the full copyright and license information, please view the > LICENSE > * file that was distributed with this source code. > */ > > /** > * sfCommonFilter automatically adds javascripts and stylesheets > information in the sfResponse content. > * > * @package symfony > * @subpackage filter > * @author Fabien Potencier <[EMAIL PROTECTED]> > * @version SVN: $Id: sfCommonFilter.class.php 4593 2007-07-13 > 11:47:43Z fabien $ > */ > class sfCommonFilter extends sfFilter > { > /** > * Executes this filter. > * > * @param sfFilterChain A sfFilterChain instance > */ > public function execute($filterChain) > { > // 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'); > } > } > > Thanks Alistair > > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
