简体   繁体   中英

How to remove JavaScript file from Wordpress theme

I'm customizing a WP theme but I cannot remove one JS which I don't need. I have deleted it from the folder but it still renders in html.

There are 5 JQuery files in theme's js folder + one called base.js which seems to handle some objects but it has nothing to do with the JS I don't want to include.

So rendered html looks like this:

<script type='text/javascript' src='../wordpress/wp-content/themes/custom-theme/js/jquery.prettyPhoto.js?ver=3.7'></script>
<script type='text/javascript' src='../wordpress/wp-content/themes/custom-theme/js/jquery.fitvids.js?ver=3.7'></script>
<script type='text/javascript' src='../wordpress/wp-content/themes/custom-theme/js/jquery.innerfade.js?ver=3.7'></script>
<script type='text/javascript' src='../wordpress/wp-content/themes/custom-theme/js/jquery.backstretch.min.js?ver=3.7'></script>
<script type='text/javascript' src='../wordpress/wp-content/themes/custom-theme/js/base.js?ver=3.7'></script>
<script type='text/javascript' src='../wordpress/wp-content/themes/custom-theme/js/jquery.flexslider-min.js?ver=3.7'></script>

and I don't need the last one - FlexSlider for I'll be using a different one

There's an inline JS that also renders in html, and I want to remove it as well - I've opened each and every file in the theme folder and I couldn't find this piece of code anywhere

<!-- Flex Slider -->
<script type = "text/javascript"> 
jQuery(window).load(function () {
    // Slider
    jQuery('#slider').flexslider({
        animation: "fade",
        slideDirection: "horizontal",
        slideshow: true,
        slideshowSpeed: 7000,
        animationDuration: 600,
        directionNav: true,
        keyboardNav: true,
        randomize: false,
        pauseOnAction: true,
        pauseOnHover: false,
        controlsContainer: ".slideshow",
        animationLoop: true
    });
});
</script>

Any ideas on how I can prevent this JS from rendering and add a different one.

Thank you!

You will need to find where those files are being included. Generally, with Wordpress, the JS files are included from the address of the plugin folder. So it's strange that they're being included from your base JS folder.

I'm not sure why this would be happening. But you will need to find where these files are being called from and delete that code.

Considering the names of the JS files, I would search within the relative plugin folder for each file. EG Look in the pretty Photo plugin folder for the line that includes that JS file.

This will be tedious, but you don't want those files being called if they don't exist. This hurts load times.

Mozilla firefox provide add-once "firebug". Which is may be help you. First install mozilla firebug and restart mozilla and load the wordpress page where your file rendering and now press F12 and you can see all the files which in included from wordpress theme and you can also see the location of included files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM