This can be easily circumvented by distributing compressed/cacheable css/js
in one minified/aggregated file. Combine that with good markup and an
onDomReady event and the user experience will not suffer.
- Dustin
On 3/31/08 3:53 PM, "rDeeb" <[EMAIL PROTECTED]> wrote:
>
> If you put the javascripts at the bottom you may be breaking the site
> usabillity, imagine you have a nice animation in your flash message,
> just like the ones wordpress uses (I did one for the Admin Generator
> Flash messages). And after the page renders, you start loading the JS
> that are required for the animations, I use mootools, an aprox of 60k
> with all features, but if you load prototype + script.acolo.us (or
> whatever it spelled) could be ~ aprox 150 k or more, so your flash
> message will animate (flash, fade or wipe in) after what 2,3,4 or 5
> seconds after you saw the page? This breaks up the usabillity you
> managed to build with JS, even if you use the onDomReady function you
> will have to wait for all the library to load up. I rather prefer to
> wait while the page loads the JS and start using it right away, than
> see the page but can't fully use it cause it doesn't works cause no JS
> had been loaded.
>
> On Mar 25, 2:49 pm, "Alistair Stead" <[EMAIL PROTECTED]>
> wrote:
>> 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(pret
>>> ty
>>>>>> 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
-~----------~----~----~----~------~----~------~--~---