Functions can be stored and included in the code of any CDF file.

  1. Place the package where Wolfram Player can find it. If the package is used only by a specific CDF file, place it in the same folder as your CDF file. If you would like to reuse the package, place it in the Wolfram Player’s apps folder:

    On Windows:

     C:\Program Files\Wolfram Research\Wolfram Player\12.0\AddOns\Applications 

    On macOS:

     /Applications/Wolfram Player.app/AddOns/Applications 

    In either case, note the folder in which you have placed the CDF package.

  2. Load the package inside the Initialization option for the Manipulate or DynamicModule, providing its complete path:
     Initialization -> {Needs["mypackage`", "PathToPackage" <> "mypackage.wl"]}  

    Where “PathToPackage” is the folder from Step 1.

  3. When calling functions from the package, provide the context of the function, which is the package name. For example, to use myfunc[] from package mypackage.wl, use the following code:
     mypackage`myfunc[]