Tutorial: Removing the version number of JS and CSS in WordPress theme

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

In WordPress theme, we will often see in the page source JS and CSS See version number, if from the Wp_enqueue_script and Wp_enqueue_style functions in WordPress added JavaScript and CSS What about the unnecessary version number of the file? This article demonstrates how to prevent the script and style of a WordPress theme or plug-in from adding version numbers and easily remove them without adding any additional PHP functions.

  

When we open the source of the blog, we will see every JS and CSS with version number. Now that you are using the Wp_enqueue_script and Wp_enqueue_style functions to load JS and CSS. We do this by targeting the two functions to remove the version number.

Note: These functions are commonly used in functions.php files in your subject's links to CSS & JS files.

Here we pass the documentation for the Wp_enqueue_script function.

Functions Wp_register_script,wp_enqueue_style and Wp_register_style are identical to Wp_enqueue_script and have a $ver parameter.

If you must specify a version to your JS or CSS, just place the version number in the $ver parameter in single quotes. If you do not want to specify a version, you can set it to false, but this is equal to the current version of WordPress version number will automatically be added as JS or CSS version number.

To prevent your JS and CSS from loading WordPress using version number, all you need to do is use null values in the $ver parameters. Here's how you can implement it in the WordPress enqueue function:

<?php wp_register_script (' Basic ', Plugins_url (' Js/basic.js ', __file__), array (), NULL, true); >

Similar wp_register_script,wp_enqueue_style and Wp_register_style are used in the same usage. It's as simple as that.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.