This broke for error pages and custom content types and search pages
-
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.
- The topic ‘This broke for error pages and custom content types and search pages’ is closed to new replies.