Rewrite plugin javascript