AE Expressions as separate script files - enabling version control (git)
When using AE Expressions, make it possible for After Effects to save these scripts as separate files (outside the AE project). That way, when cooperating with others on projects involving scripting, you could enable version control of the scripts - i.e. use git.

In an effort to improve communications between you and the After Effects team, we are moving this feedback forum to the After Effects page on the Adobe Support Community. As requested, bugs and feature requests will be able to live separately in that forum. If you have an item here that did not make the migration, please bring it over to our new home.
See you soon on the Adobe Support Forum!
-
Kjetil Svendsen commented
Hi Tim. Thanks for your reply.
Ok, this sounds like a good start if I want to start using Git for version control of my mogrt-project.
However - a couple of suggestions.
Instead of having to declare the function each time, how about adding @import MyFunctions.jsx which will enable me to use the functions in several expressions.Also, how about having files for the expressions themselves, not just the functions it references, so that these could also be updated from outside AE, and hence version controlled when collaborating with others.
(Or just add the possibility to Export to Motion Graphics Template when working in Team Projects (I've filed this under a separate post)).
-
In After Effects 15.1, JSX files can be imported just like footage and then referenced using expressions. (This was also possible in 15.0, although the extension was .JSON, and this caused a problem with upgrades to the JSON parser in 15.1; proper JavaScript code is not actually legal in JSON schema!)
I'd like to give you an example. Since I can't attach files here, we'll do it by text.
First, create a new text file. Save it with the .jsx extension (ex., "myFunctions.jsx").
Copy the following into the file (two functions that calculate the circumference of a circle given an input value) and save it:
{
"circumferenceFromDiameter" : function(diameter) {
return diameter * Math.PI
},
"circumferenceFromRadius" : function(radius) {
return radius * 2 * Math.PI
}
}Now import that JSX file into After Effects 15.1.
Create a new text layer, and add this expression to the Source Text property:
footage("MyFunctions.jsx").sourceData.circumferenceFromDiameter(5)("5" can be any value, it's simply the input value for the function.)
This will return the result of the function, calculating the circumference of a circle with the given diameter, to the text layer.
If you want to easily reference the function multiple times in an expression, you can declare it as a function in the expression:
function myFunction(myValue) { return footage("MyFunctions.jsx").sourceData.circumferenceFromDiameter(myValue)};
myFunction(5)Once you've created the expression, you can save it as an animation preset (Animation menu > Save Animation Preset). Of course, for the preset to work in future projects, you will need to have the JSX file present in the project. To help with that, you can create a project template and set it as your default project in Preferences > New Project > New project loads template.
If you edit the JSX file outside of After Effects, the changes will be automatically recognized when you save the file.
Finally, although the expression references the JSX file as a footage object, you should add the JSX file to the composition you use it in. This is because certain functions that create a copy of the project, like exporting a Motion Graphics template or using Adobe Media Encoder to render the comp, do not remember to look at expression references to footage objects and will fail to copy the file. (We consider this a bug.) But if you add the JSX file to the composition, the file will be copied.
I hope that helps clarify what is currently possible in After Effects. If you see additional functionality that you'd like, let's continue the discussion here, or you can create separate requests.
-
Kjetil Svendsen commented
@Duduf: How would I go about linking to the jsx?
Do they have to be imported each time or would I be able to edit the jsx outside of AE? -
Duduf commented
With 15, you can import data files which contain jsx functions which can be used in expressions ;)