如何删除网站源代码中的css和javascript代码

How to remove css and javascript code in source code of website

我已经在我的网站上安装了 Slicknav Menu 插件。现在,当我转到我网站的主页和 运行 源代码时,我看到了这个插件的一部分 css 和脚本代码:

<head>
       ...
<style id='slicknavcss-inline-css' type='text/css'>
        .slicknav_menu {
                            display: none;
                        }
                    @media screen and (max-width: 768px) {
                        #responsive-menu {
                          display: none;
                       }
                       .slicknav_menu {
                          display: block;
                          background: #8c8c8c;
                       }
                       .slicknav_btn {
                          background-color:#f7634c;
                          float:right;
                       }
                       a.slicknav_open {
                          background-color:#dd3333;
                       }
                      ...
    </head>

头部的脚本代码也是:

<script type='text/javascript'>
/* <![CDATA[ */
var slickNavVars = {"ng_slicknav":{"ng_slicknav_menu":"#responsive-menu","ng_slicknav_position":"body","ng_slicknav_parent_links":true,"ng_slicknav_close_click":true,"ng_slicknav_child_links":false,"ng_slicknav_speed":400,"ng_slicknav_label":"","ng_slicknav_fixhead":false,"ng_slicknav_brand":"","ng_slicknav_search":false,"ng_slicknav_search_text":"search...","ng_slicksearch":"http:\/\/ali-coupons.net\/","ng_slicknav_closedsymbol":"\u25ba","ng_slicknav_openedsymbol":"\u25bc","ng_slicknav_alt":""}};
/* ]]> */
</script>

是否有从源代码中的 header 中删除此代码的想法?

这里是插件的 php 文件中的代码,它在网站的源代码头中生成样式和脚本:

        //All the user input CSS settings as set in SLicknav settings
        $slicknav_custom_css = "
                .slicknav_menu {
                    display: none;
                }
            @media screen and (max-width: {$ng_slicknav_width}px) {
                {$ng_slicknav_menu} {
                  display: none;
               }
               .slicknav_menu {
                  display: block;
                  background: {$ng_slicknav_background};
               }
               .slicknav_btn {
                  background-color:{$ng_slicknav_button};
                  float:{$ng_slicknav_button_position};
               }
               a.slicknav_open {
                  background-color:{$ng_slicknav_button_expand};
               }
               .slicknav_nav .slicknav_arrow {
                  float:{$ng_slicknav_submenu_position};
               }
               .slicknav_menu .slicknav_menutxt {
                  color: {$ng_slicknav_label_color};
                  text-shadow: {$ng_slicknav_label_shadow};
                  font-size: {$ng_slicknav_label_size}px;
                  font-weight: {$ng_slicknav_label_weight};
               }
               .slicknav_menu .slicknav_icon-bar {
                  background-color: {$ng_slicknav_icon_color};
                  box-shadow: {$ng_slicknav_icon_shadow};
               }
               .slicknav_nav li a {
                  color: {$ng_slicknav_link_color};
                  text-transform: {$ng_slicknav_font_case};
                  font-size: {$ng_slicknav_font}px;
                  padding: 5px 10px;
               }
               .slicknav_nav a:hover,
               .slicknav_nav .menu-item a:hover,
               .slicknav_nav .slicknav_row:hover {
                  background: {$ng_slicknav_link_hover_color};
                  color: {$ng_slicknav_link_hover_text_color};
               }

               .slicknav_nav input[type='submit']{
                  background: {$ng_slicknav_search_color};
               }

           }";
          //If Menu button is set to left, move brand logo to right, set in Slicknav settings
         if( $ng_slicknav_button_position == "left"  )
        $slicknav_custom_css .= "
              .slicknav_brand {
                 float: right;
              }";
        //Fix menu to position in header if set in Slicknav settings
          if( $ng_slicknav_fixhead == true )
        $slicknav_custom_css .= "
         @media screen and (max-width: {$ng_slicknav_width}px) {
             .slicknav_menu {
                position: fixed;
                width: 100%;
                left: 0;
                top: 0;
                z-index: 999999;
            }
             html {
                padding-top: 45px;
             }
         }";
        //Hide header if option is clicked in SlickNav settings
        if( $ng_slicknav_header == true )
     $slicknav_custom_css .= "
        @media screen and (max-width:{$ng_slicknav_width}px) {
             .site-header {
                display: none;
             }
        }";

  }
  //add the above custom CSS via wp_add_inline_style
  wp_add_inline_style( 'slicknavcss', $slicknav_custom_css );
}

add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\responsive_menucss' );

SlickNav WordPress 插件正在添加该代码。您可以自己以更正常、正确的方式加载该代码:http://slicknav.com/。确保在 jQuery 加载后加载 SlickNav js。