Custom script to collapse or hide sidebar on form view

Hello,

Which is the best way to collapse sidebar by default using a custom script in certain DocType?

Thanks.