How to call function from other javascript


I suggested some idea of javascript library. for pascal users a unit. so tring to make that myself.
But sofar all examples i have tried on internet seems not copatible with hfi. or im doing it wrong.
because building your own units/library’s can be usefull with hifi.

Can you call from 1 javascript a function from other javascript ? and how’s that done in hifi ?


I haven’t looked at it but yes it will be useful and eventually it will probably work in some form because people are likely to want to interact with the likes of Perl or PHP for some functionality I’d imagine.


Only thing i wanted is to call a function from javascript B and parce parameters if needed to a function in javascript B. that way you can make function and reuse it, thats the idea.


To my knowledge you can’t do that, but you can copy the function from the other script and incorporate it into your script.


I agree with that, i have seen javascript to much like normal programming language. But that can not work in a virtual world sofar i know. to much overhead and unwanted memory useage.


If one script includes the other script then you can share variables and functions. For example, editModels.js includes toolBars.js in order to use the latter’s Overlay2D, Tool, and ToolBar objects.

The trick is that items declared with “var” aren’t shared but items declared without “var” are shared as properties of the global object which is common to the two scripts if one includes the other.


This is possible - for example, all the separate animation files for the procedural controller are loaded and functions called by the main script (walk.js).

Also, some scripts load up the proceduralAnimationAPI.js script ( ) and use it’s functions

Regarding script resource usage, so far I’ve been both surprised and impressed by how much computation I can get JS to do in one frame - HiFi JS is certainly far, far more powerful than LSL!
We do need to keep an eye on this though. I plan to start implementing some very basic resource usage tools this week…

  • davedub


I made a script that i want to show friday. But already discovered that o can push hifi over the framerate edge when i do to many things in short time. So good script for the resource test. Adjusted the script now so the framerate dont drop on my screen.


@Richardus - I’m very much looking into script limits at the moment - can I ask a couple of questions?

  1. When you push HiFi over the framerate edge, what sort of operations are you doing? e.g. filling up big arrays, doing lots of maths, transforming images - would be useful to know.

  2. How do you detect when the framerate edge is hit? Does the viewer start running laggy or are you measuring frametimes?

  3. Could I get a copy of your script with some brief notes on how to push it over the limits?


  • davedub


@Chris got the same script from me @davedub, he wanted to send it to soemone but i forgot the name. You can have the same script, if i know to where i need to send it.

The framerate is dropping for me when you let more entitys appear.
Also on @Ai_Austin domain my framerate is droppen because some more heavy mesh,
you better ask @Ai_Austin about that Only looking at the FPS meter, if that start tod drop things start to move less smooth and thats something i never like :open_mouth:

Lagg in High Fidelity, uhmm, need to figure out first what is lag in High Fidelity :wink:


There is definitely a need to be able to include one file and to be able to call its internal methods and access its variables from another. We need shared memory space for Javascript includes. Including it multiple times is lame.