• Resolved rvance

    (@rvance)


    Hi, nifty plugin. It worked for most of my site. However, I needed to ignore deferring jQuery on Home, Pages, and Posts. Sadly, this did not cover my search, 404 page or custom content types. I have to edit your code.

    I have added the following on line 521 on fvm.php

        /**
         * adding my custom types and content types not covered by this plugin
         */
        if(is_post_type('post_type_here') && $exclude_defer_jquery_posts == '1'){$ignore[] = $hurl;}
        if(is_post_type('post_type_here') && $exclude_defer_jquery_posts == '1'){$ignore[] = $hurl;}
        if(is_post_type('post_type_here') && $exclude_defer_jquery_posts == '1'){$ignore[] = $hurl;}
        if(is_404() && $exclude_defer_jquery_posts == '1'){$ignore[] = $hurl;}
        if(is_search() && $exclude_defer_jquery_posts == '1'){$ignore[] = $hurl;}

    Obviously, replace ‘post_type_here’with your own post type. I also added this to my functions.php

    /**
     * Function to identify custom post types easily
     * @author Russell Vance <[email protected]>
     * @since 11/22/2016
     * @example if(is_post_type('some_post_type_here')){ //do something }
     */
    function is_post_type($type){
        global $wp_query;
        if($type == get_post_type($wp_query->post->ID)) return true;
        return false;
    }

    Now I know you make an update, I click update and poof this is gone. So this isn’t a long term solution. Is it possible to get the option to ignore jQuery on all page/Post/content types?

    is_404() and is_search() should be easy enough to implement. The custom content types, maybe a place in the admin to type them in and add a variable number of them. I will leave that up to you. The plugin rocks, helped me shave off half my load time with little effort. It just needs some tweaks to be perfect.

Viewing 1 replies (of 1 total)
  • Plugin Author Raul P.

    (@alignak)

    Hi!

    I get your point and I’ve added support for search and 404 pages on version 1.3.3 … however, bare in mind that those options are meant to be a “quick option” and not to cover for all cases.

    For example, one may need blocking jQuery on certain sections while it doesn’t matter on others (think sliders, some specific scripts, etc).

    If you want to ignore jQuery everywhere, you can simply add that url to the ignore list.
    Don’t forget the http or https full path, it has to match exactly.
    Wildcards will come soon on a next version.

Viewing 1 replies (of 1 total)
  • The topic ‘This broke for error pages and custom content types and search pages’ is closed to new replies.