Forum Discussion

Inactive User's avatar
Inactive User
12 years ago

json2.js

I noticed Lithium brings in json2.js. However, I need it to be loaded higher on the page or link to it earlier. Is there a good way to do this? I noticed the full path URL to the file includes a long string that looks temporary and random (https://lithiumstage.usaa.com/t5/scripts/829F1A6A96AAB376B634183C87A364EA/json2.js), otherwise I'd just use that.

 

Thanks

  • DavidE's avatar
    DavidE
    12 years ago

    Hey jlutterlog,

     

    We have a Loader util which allows you to add functions to be run as the page finishes loading:

     

    LITHIUM.Loader(function() { //do something });

     

    David

  • Inactive User's avatar
    Inactive User
    12 years ago

    Nevermind. Needed to be LITHIUM.Loader.onLoad(function(){  })

5 Replies

  • VenkS's avatar
    VenkS
    Lithium Alumni (Retired)
    12 years ago

    Could you please explain the use case? Is there a specific reason you need json2.js loaded higher on the page? Thanks!

     

    Sincerely,

    Venk

  • Inactive User's avatar
    Inactive User
    12 years ago
    Yes, we're using EasyXDM to make a cross-domain ajax call. This call needs to be made as the component loads which needs json2.js before it gets there. Even with onloads for later on in the page, it seems to need the file before the component loads.
  • DavidE's avatar
    DavidE
    Lithium Alumni (Retired)
    12 years ago

    Hey jlutterlog,

     

    We have a Loader util which allows you to add functions to be run as the page finishes loading:

     

    LITHIUM.Loader(function() { //do something });

     

    David

  • Inactive User's avatar
    Inactive User
    12 years ago
    That sounds like it might work. Any idea why I'd be getting this error when I try to use it? "Uncaught TypeError: Property 'Loader' of object #<Object> is not a function"

    I tried putting it in a regular script tag and in the @liaAddScript tag
  • Inactive User's avatar
    Inactive User
    12 years ago

    Nevermind. Needed to be LITHIUM.Loader.onLoad(function(){  })