How can I remove the Wordpress-Version (?ver=5.x) from my plugin

I am working on my first plugin that adds a external script to the footer. Wordpress automatically adds the version number at the end, which I'm trying to remove. What I have so far:

add_action('wp_enqueue_scripts', array($this,'print_code'));

public function print_code(){
         
        $location   =   get_option('location_select');
        $url        =   'https://' . esc_html($location) . '.domain.com/js/script.js';
        wp_enqueue_script('myID', $url, array('jquery'), false, true);


     }

This puts out the script correctly, but I still have the version (?ver=5.8) at the end. The false should avoid that, afaik. What am I missing?

Topic footer wp-enqueue-script plugin-development plugins Wordpress javascript

Category Web


Change the 4th parameter from false to null.

wp_enqueue_script( 'myID', $url, array( 'jquery' ), null, true );

From the wp_enqueue_script() documentation:

$ver
(string|bool|null) (Optional) String specifying script version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version number is automatically added equal to current installed WordPress version. If set to null, no version is added.

(emphasis added)


As defined in the codex,

If version is set to false, a version number is automatically added equal to current installed WordPress version. If set to null, no version is added.

You're currently setting false. You should be setting null:

wp_enqueue_script('myID', $url, array('jquery'), null, true);

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.