« Return to Thread: Javascript at the end of a page

Re: Javascript at the end of a page

by Burt Beckwith :: Rate this Message:

Reply to Author | View in Thread

Very slick, I'm definitely borrowing that.

Burt

On Wednesday 13 August 2008 4:08:46 am dear_stephen wrote:

> I have come up with a solution that works well. I created the following
> tags.
>
> def dependantJavascript = { attrs, body ->
> flash.dependantJavascript = body()
> }
> def renderDependantJavascript = {
> out << flash.dependantJavascript
> }
>
>
> In my desorated page I have ...
> <g:dependantJavascript>
>   <script src="thisPageSpecificScriptDependantOnGlobal.js"></script>
> </g:dependantJavascript>
>
> In my decorator page I put the following.
> <script src="global.js" />
> <g:renderDependantJavascript />
>
> Hates_ wrote:
> > Ah yes. I hadn't taken the actual evaluation time of the script into
> > consideration. It's just one of those things I take for granted (and
> > really shouldn't) as I've never noticed a perceivable impact on loading
> > times by my scripts.
> >
> > You could always roll your own javascript tag that will include the
> > global.js file before appending your dependant one to the page. But it
> > would get messy if you have multiple JS includes and isn't an ideal
> > solution in my mind:
> >
> > <g:dependantJavascript  src="thisPageSpecificScriptDependantOnGlobal.js"
> > />
> >
> > and plain
> >
> > <g:javascript  src="thisPageSpecificScriptNotDependantOnGlobal.js" />
> >
> > Or use Javascript to include the Global.js file within itself.



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Javascript at the end of a page