Move the JavaScript code remotely and convert all $wpdb database calls to native PDO (PHP) calls.
$wpdb
Website calls remote sa.js which POSTs to email-basic.php and pageview.php.
sa.js
POST
email-basic.php
pageview.php
Pagespeed Optimization by Lighthouse.