Optimisation of js