How to delete the version number tail of WordPress scripts and CSS style sheets

As an excellent website building program, WordPress is undoubtedly the largest user group in the world in terms of user volume. Because of the powerful function, we need to consider the application compatibility to various functional requirements in the process of program design, so when we use the default WP program, it will be very cumbersome. But if users can optimize the CMS well, it will be faster and more beautiful.

Today, when we was managing a WordPress website, he saw that the header code, JS script and CSS style sheet were ugly, with the tail of version number.

Let’s look at the tail of scripts and stylesheets before they are processed. It’s ugly. How to deal with it?

function sb_ remove_ script_ version( $src ){
$parts = explode( ‘?’, $src );
return $parts[0];
add_ filter( ‘script_ loader_ src’, ‘sb_ remove_ script_ version’, 15, 1 );
add_ filter( ‘style_ loader_ src’, ‘sb_ remove_ script_ version’, 15, 1 );
add_ action(‘login_ enqueue_ scripts’,’login_ protection’);

In Functions.php Add the above code to the file. Then let’s take a look at the script. The tail version number of the stylesheet and JS script has been removed. The code is much clearer.

Related Article
Implementation of tag inner chain association effect of WordPress program without plug-in

Nowadays, whether it is a large website or a personal blog, what matters is not the weight of the website Read more

Is in WordPress Theme_ Home () and is_ front_ Different usage of page ()

Under normal circumstances, when we use WordPress to build a website, the home page is the default index.php Just call Read more

Solve the problem of “upload error, please try again later” in WordPress image upload

One of the reasons why I like to use WordPress is that I have encountered problems. Basically, I can find Read more

Methods to disable / delete URL form item of WordPress comment website

If we use the default theme of WordPress or most of the themes, there are several options in the comments, Read more

Leave a Reply

Your email address will not be published. Required fields are marked *

To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image