Get JS file parameter

// Get the URL of the current JavaScript file var scriptUrl = document.currentScript.src; // Extract the query string from the URL var queryString = scriptUrl.split('?')[1]; // Parse the query string into a URLSearchParams object var searchParams = new URLSearchParams(queryString); // Get the value of the 'id' parameter var idValue = searchParams.get('id'); // Do something with the 'id' value console.log('The id value is:', idValue);