Re: JavaScripts generated programmatically and/or placed at the end
Re: JavaScripts generated programmatically and/or placed at the end
- Subject: Re: JavaScripts generated programmatically and/or placed at the end
- From: Aaron Rosenzweig via Webobjects-dev <email@hidden>
- Date: Mon, 27 Jan 2020 17:06:25 -0500
Hi OC,
Offhand what you are asking is probably possible; however I have a suggestion
to not fight against the grain.
If you are using prototype, then wait for the “dom loaded event” like so:
http://api.prototypejs.org/dom/document/observe/
<http://api.prototypejs.org/dom/document/observe/>
jQuery has something similar:
https://api.jquery.com/ready/ <https://api.jquery.com/ready/>
If you aren’t using either you could choose window or document onLoad:
https://stackoverflow.com/questions/588040/window-onload-vs-document-onload
<https://stackoverflow.com/questions/588040/window-onload-vs-document-onload>
In this way, you can put it in the head, and then it will only be executed
after all the DOM elements are on the page :-)
AARON ROSENZWEIG / Chat 'n Bike <http://www.chatnbike.com/>
e: email@hidden <mailto:email@hidden> t: (301) 956-2319
> On Jan 26, 2020, at 12:09 PM, OCsite via Webobjects-dev
> <email@hidden> wrote:
>
> Hi there,
>
> for once, no deep mystery, but a plain API-related question :)
>
> I am just switching my old very hap-hazard and ugly way of loading
> javascripts as needed by components to the very neat ERXComponent's support
> of additionalJavascriptFiles. Mostly it works like a charm, but for two cases:
>
> (i) scripts which are generated programmatically
>
> So far, I have used directly in the particular component template something
> like
>
> ===
> <wo:ERXJavaScript scriptKey="cz.ocs.SomeScript.generated">
> <wo:string value="$generatedSomeJS" escapeHTML="no"/>
> </wo>
> ===
>
> Is there a way to exploit somehow the ERXComponent's support for that, to
> move these scripts to the <head> too?
>
> (ii) scripts which need to be placed at the end of page
>
> Far as I was able to ascertain, all the <script...> tags for the scripts from
> additionalJavascriptFiles are always generated to <head>. Mostly it's
> precisely what I need, but time to tome, the script needs to be placed at the
> end of page (for it runs something which addresses the page elements). Is
> there a way to use the ERXComponent's support for that?
>
> Thanks a lot,
> OC
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden