How to parse GET or POST variables to JavaScript via PHP

For a customer, I had to find a way to parse $_GET or $_POST variables to a widget running JavaScript code on another server.

I used a piece of code by Pippin Williamson to only load the necessary javascript script if the shortcode is used on the page we're viewing.

Load Scripts if Post has Short Code.

My modified version looks for a specific parameter ?restid=, and if it exists loads the JavaScript file with the parameter parsed via the wp_localize_script() function. This way the .js file can use that value to continue processing.

The jQuery code is here: