WordPress优化技巧:删除CSS和JS文件后面的版本号

前端之家收集整理的这篇文章主要介绍了WordPress优化技巧:删除CSS和JS文件后面的版本号前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

使用wordpress做完网站以后,当我们查看网站源代码的时候,发现wordpress调用自身或插件的CSS文件和JS文件的后方都带着版本号,如下图:

version

这样看起来既不美观,又暴漏了我们使用的wordpress的信息。这篇wordpress教程里我们将向大家介绍一下如何移除wordpress调用的CSS和JS文件后面的版本号。

切换到主题目录,打开functions.PHP文件,加入以下代码

Crayon-5c891d1502728335857607" class="Crayon-Syntax Crayon-theme-classic Crayon-font-monaco Crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouSEOver" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
Crayon-toolbar" data-settings=" mouSEOver overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-title">functions.PHP
Crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-mixed-highlight" title="Contains Mixed Languages">
Crayon-button Crayon-nums-button" title="Toggle Line Numbers">
Crayon-button-icon">
Crayon-button Crayon-plain-button" title="Toggle Plain Code">
Crayon-button-icon">
Crayon-button Crayon-wrap-button" title="Toggle Line Wrap">
Crayon-button-icon">
Crayon-button Crayon-expand-button" title="Expand Code">
Crayon-button-icon">
Crayon-button Crayon-copy-button" title="Copy">
Crayon-button-icon">
Crayon-button Crayon-popup-button" title="Open Code In New Window">
Crayon-button-icon">
Crayon-language">PHP
Crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
Crayon-plain-wrap">
Crayon-main" style="">Crayon-table">Crayon-row">
Crayon-nums " data-settings="show">
Crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
Crayon-num" data-line="Crayon-5c891d1502728335857607-1">1
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1502728335857607-2">2
Crayon-num" data-line="Crayon-5c891d1502728335857607-3">3
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1502728335857607-4">4
Crayon-num" data-line="Crayon-5c891d1502728335857607-5">5
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1502728335857607-6">6
Crayon-num" data-line="Crayon-5c891d1502728335857607-7">7
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1502728335857607-8">8
Crayon-num" data-line="Crayon-5c891d1502728335857607-9">9
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d1502728335857607-10">10
Crayon-code">
Crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
Crayon-line" id="Crayon-5c891d1502728335857607-1">Crayon-ta">PHP
Crayon-line Crayon-striped-line" id="Crayon-5c891d1502728335857607-2">Crayon-h"> Crayon-c">// remove wp version param from any enqueued scripts
Crayon-line" id="Crayon-5c891d1502728335857607-3">Crayon-h"> Crayon-t">functionCrayon-h"> Crayon-cn">91wordpress_remove_wp_ver_css_jsCrayon-sy">(Crayon-h"> Crayon-v">$srcCrayon-h"> Crayon-sy">)Crayon-h"> Crayon-sy">{
Crayon-line Crayon-striped-line" id="Crayon-5c891d1502728335857607-4">Crayon-h"> Crayon-st">ifCrayon-h"> Crayon-sy">(Crayon-h"> Crayon-e">strposCrayon-sy">(Crayon-h"> Crayon-v">$srcCrayon-sy">,Crayon-h"> Crayon-s">'ver='Crayon-h"> Crayon-sy">.Crayon-h"> Crayon-e">get_bloginfoCrayon-sy">(Crayon-h"> Crayon-s">'version'Crayon-h"> Crayon-sy">)Crayon-h"> Crayon-sy">)Crayon-h"> Crayon-sy">)
Crayon-line" id="Crayon-5c891d1502728335857607-5">Crayon-h"> Crayon-v">$srcCrayon-h"> Crayon-o">=Crayon-h"> Crayon-e">remove_query_argCrayon-sy">(Crayon-h"> Crayon-s">'ver'Crayon-sy">,Crayon-h"> Crayon-v">$srcCrayon-h"> Crayon-sy">)Crayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891d1502728335857607-6">Crayon-h"> Crayon-k ">returnCrayon-h"> Crayon-v">$srcCrayon-sy">;
Crayon-line" id="Crayon-5c891d1502728335857607-7">Crayon-h"> Crayon-sy">}
Crayon-line Crayon-striped-line" id="Crayon-5c891d1502728335857607-8">Crayon-h"> Crayon-e">add_filterCrayon-sy">(Crayon-h"> Crayon-s">'style_loader_src'Crayon-sy">,Crayon-h"> Crayon-s">'91wordpress_remove_wp_ver_css_js'Crayon-sy">,Crayon-h"> Crayon-cn">9999Crayon-h"> Crayon-sy">)Crayon-sy">;
Crayon-line" id="Crayon-5c891d1502728335857607-9">Crayon-h"> Crayon-e">add_filterCrayon-sy">(Crayon-h"> Crayon-s">'script_loader_src'Crayon-sy">,Crayon-h"> Crayon-cn">9999Crayon-h"> Crayon-sy">)Crayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891d1502728335857607-10">

原文链接:https://www.f2er.com/wordpress/238451.html

猜你在找的wordpress相关文章