rewrite ajax loading javascripts as jquery plugin