Fragments are light-weight UI parts (UI sub-trees) which can be reused, defined similar to views, but do not have any controller or other behavior code involved
There is no separate procedure for js and xml fragment. Concept vis it is same, you need to change the type of fragment when you initialize.
JS: https://help.sap.com/saphelp_uiaddon10/helpdata/en/9c/069828d0064136ac6a499aa2cdace3/content.htm
e.g:
oFragment = sap.ui.xmlfragment(this.fragmentName.bind(this));
or
oFragment = sap.ui.jsfragment(this.fragmentName.bind(this));
Use add dependency property to add methods from this.controller.
Regards,
Karthik A