Reply
Highlighted
Visitor
Posts: 3
Registered: ‎06-14-2016

how to load js file and use functions from same file

Hi,

I am facing one issue with tealium custom container. I have added new tealium custom container template and loading js file from the template . Added another extension scope to after tags , when i try to call function from the js which i loaded from the template i am getting error saying that function not defined . i can see that function is not available by the time extension is loading . 

Is there any other solution in tealium to fix this issue ?

Thank you,

Veeru

 

 

 

 

 

 

Reply
0 Kudos
Occasional Contributor
Posts: 106
Registered: ‎12-11-2015

Re: how to load js file and use functions from same file

[ Edited ]

The delay is likely to be caused by either:

  1. The asynchronous loading of the tag file, or
  2. The asynchronous loading of the script

Or indeed both of those. Your best options, @vveerendra, are either to change the way in which the scripts are loaded (potentially bundling the tag into the main utag.js and loading the script in the container synchronously) or otherwise change the way in which you're trying to use the functions that the tag creates. If you're doing the latter, this might mean attaching the subsequent scripts to the onload attribute of the script you're adding, or polling for the existence of the required functions at intervals and holding off on using them until they're there.

Tealium Employee
Posts: 36
Registered: ‎09-01-2015

Re: how to load js file and use functions from same file

@vveerendra

Are you using u.loader to load your JS file?

If so, you can un-comment the u.loader_cb function and put your function calls where it says "Insert your post-Loader tag sending code here." These function calls will execute after your external JS file has loaded.
Visitor
Posts: 3
Registered: ‎06-14-2016

Re: how to load js file and use functions from same file

[ Edited ]

I tried bundling the tag, @UnknownJ, but i am still seeing the same issue

Reply
0 Kudos
Visitor
Posts: 3
Registered: ‎06-14-2016

Re: how to load js file and use functions from same file

[ Edited ]

Hi @adam_wolfers,

I was able to fix using diffenent method . But i will also check your solution and let you in case of any issues.

Thanks!

Reply
0 Kudos
Community Manager
Posts: 1,019
Registered: ‎08-26-2015

Re: how to load js file and use functions from same file

[ Edited ]

Glad to hear that you fixed the issue using a different method @vveerendra. Would you mind replying and letting us know how you did it? I look forward to reading your approach. 

Remember to give me a kudo if you like my post! Accepting my post as a solution is even better! Also remember that search is your friend.
Reply
0 Kudos