JSObject jsextension_load(JSContextRef ctx);
This function will use the supplied JSContextRef to create a class and make and return an object of that class. The class will contain static functions and possibly values that you want the extension to export and is defined through a JSClassDefinition structure instance.
The class definition is passed in as an argument to a call to JSClassCreate. You only need a single class instance for the lifetime of your dynamic library. Once the class instance exists, an object can be made using the JSObjectMake call, and this object is the return value of your jsextension_load function.
The next step to to build a dynamic library which exports jsextension_load. Once this is complete, you then need a way of loading the extensions. This could involve specifying the name of the dynamic library to open, or simply scanning a specified directory for dynamic libraries, opening them and seeing if they export a jsextension_load symbol.
This post will look at two ways of loading extensions. The first is by using something similar to the CommonJS "require" function. The second is adding a method to the WebView to load an extension.
where frame is the current "main" frame in the WebView.