use js to middle