It loads lot of data in form of .js file, this js file contains a big database in form of variable
This is an XY Problem. You should use a proper database and/or load the data in chunks. You are experiencing poor performance because your code is bad. Fix your code.