fix js bugs and support libraries 2.x