• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: JavaScripts generated programmatically and/or placed at the end
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >JavaScripts generated programmatically and/or placed at the end (From: OCsite via Webobjects-dev <email@hidden>)

  • Prev by Date: Re: Problem running from Eclipse
  • Next by Date: Re: Problem running from Eclipse
  • Previous by thread: JavaScripts generated programmatically and/or placed at the end
  • Next by thread: Custom Ajax Component parent page re rendereing
  • Index(es):
    • Date
    • Thread