WordPress.org

Ready to get started?Download WordPress

Ideas

Add theme version number to stylesheet url, not WP version

  1. Drivingralle
    Member

    I think the automatically added version numbers WP adds to all stylesheet/script urls could be better.

    At the moment the WP version is added if no version is specified by wp_enqueue_style. So now a browser will re-download the stylesheet if WP updates. But it's unnecessary. Also if a theme get's updated, the browser don't get to know it and uses the old css. This can lead to broken layouts.

    I would like to see WP adding the version number of the theme to styles/scripts added by the theme. Styles/scripts added by plugins should get the version number of the plugin. Files added by core shold still use the core-version.

    I use this code in my themes. Doing it automatically, would be more nice.

    // Save same data about the theme into a variable
    $child_my_theme_data = wp_get_theme();

    // Enqueue a CSS style file
    wp_enqueue_style(
    'child_style',
    get_stylesheet_directory_uri() . '/style.css',
    array(),
    $child_my_theme_data->Version
    );

    Posted: 1 month ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    0 Votes
  • Status

    This idea is under consideration