add javascript middleware