Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

wordpress - WP: how to remove version number in wp_enqueue_script?

I'm trying to remove the version number from appearing in the URL generated by wp_enqueue_script. It seems like I should pass a null on the 4th parameter per http://codex.wordpress.org/Function_Reference/wp_enqueue_script:

wp_enqueue_script('jquery', false, array(), null, false);

It's not working. I still see the version number. How do I remove that?

Also, how do I use wp_enqueue_script so that I get jQuery from the Google CDN?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can either use

wp_enqueue_script('jquery', 'URL', array(), '', false);

or

wp_enqueue_script('jquery', 'URL', array(), null, false);

or you can put a generic name placeholder

wp_enqueue_script('jquery', 'URL', array(), 'custom', false);

But particularly with "jquery" I would deregister the default if you want to replace it

wp_deregister_script('jquery');
$GoogleJqueryURI = 'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js';
wp_register_script('jquery', $GoogleJqueryURI, array(), 'custom', false);
wp_enqueue_script('jquery');

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...