Refactoring of the javascript to open a connection using the connectionPool