How to Use External Javascript Functions from within the Main.js in an App
2022년 11월 23일에 게시됨
Hello All,
I am using local storage to save data in an app. However, there is a chance it will exceed the maximum allowed size. For this reason, I have implemented a third party compression/decompression algorithm. This is in a .js file.
My problem is that I don't know how to reference the external .js file from the main.js file. For testing purposes, I have copied the third party code, wholesale, into the main.js -- but this is not an ideal situation. I would like to reference the external file so that I can use the relevant functions, and keep the third party code separate.
Can anyone advise?
Thanks,
SGL.
0
4
댓글 4개
Eric Nelson
0
SGL
Hi Eric,
I thought that was what I had done, so when it failed I came to the erroneous conclusion that Zendesk was preventing it somehow. But I just tried it again, and it was successful -- so it was my mistake. Sorry to bug you about that.
Thanks,
SGL.
0
Eric Nelson
This isn't a Zendesk specific thing. You just need to order your JS files correctly in the html file so that the file you're wanting to call functions from is loaded first. Then the main.js file will be able to use it. Here's a small example, you'll see that the main.js file uses the function from the external.js file.
Hope this helps
1
SGL
Hi Anyone,
I still haven't solved this issue. From the main code, I want to be able to call functions that are defined in a separate javascript file.
Help would definitely be appreciated.
Thanks,
SGL
0
로그인하세요.