Edit glb file using js

Hello guys
i have a glb file that contains multiple animations of my avatar
i want to know if there is a way to clone this file into a new one but with just a specific animations (using there name)

the code i’m looking for should be like this:

foreach animations as animation
if animation.name = “hello”
add it to the new glb file
else if animation.name = “hey”
add it to the new glb file

the point from the code or the idea is to reduce the glb file size
thanks in advance

You can load the glTF asset with GLTFLoader, apply your modifications and then export the scene with GLTFExporter. The usage of this class is demonstrated in the following demo:

https://threejs.org/examples/misc_exporter_gltf

thank you for your fast reply
but how can i apply my modifications?
i want to remove some animations from the original file and then create a new glb file that contains just the selected animations

GLTFExporter takes an array of animations as an option — include whichever animations you want:

https://threejs.org/docs/#examples/en/exporters/GLTFExporter.parse

This can also be done in Blender, by removing or muting NLA tracks.