Optimisation of the javascript