factorise plugin output computation in js