defer parsing javascript
-
I added this code (there may be a line or 2 of extra code in here that doesn’t pertain to the question)
add_filter( 'wp_image_editors', 'change_graphic_lib' ); function change_graphic_lib($array) { return array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); } function defer_parsing_of_js ( $url ) { if ( FALSE === strpos( $url, '.js' ) ) return $url; if ( strpos( $url, 'jquery.js' ) ) return $url; return "$url' defer "; } add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
My page speed increased on GT Metrix from a 90 to a 97. it loads in about 0.5 seconds.
The problem:
This code does not seem to effect all the posts on my blog. Some are super fast, others are not.
So I came across this code
I got it from here (I forgot where I got the first code from, sorry to the coder)https://varvy.com/pagespeed/defer-loading-javascript.html add_filter( 'wp_image_editors', 'change_graphic_lib' ); function change_graphic_lib($array) { return array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); } function defer_parsing_of_js ( $url ) { if ( FALSE === strpos( $url, '.js' ) ) return $url; if ( strpos( $url, 'jquery.js' ) ) return $url; return "$url' defer "; } add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
Will this even work, it says it is for html. And will it apply to all pages.
Another think that may or may not matter.
I put the first code in my child theme. If I put it in the real place would it workMy problem is that I have a landing page on my blog that is a slow loader. It loads at fastest 2.5 seconds and at slowest 5.5 seconds.
No one, including me, is going to wait 5.5 seconds if they are browsing. if they know the content is good they might, but for those just cruising around the web, they are going to leave.
this is my blog
https://ragingalcoholic.comCan someone tell me how to get these other pages to speed up.
The javascript parsing is always the number one reason that GT Metrix says makes some of my pages load slowly.
Thanks
and again, my apologies to the coder who didn’t get cited properly
also:
I have no idea how any of that code works or anything else. My abilities stop after I find the file and cut and paste the code into it. I don’t actually understand what I am doing. I just follow directions.
- The topic ‘defer parsing javascript’ is closed to new replies.