TagDiv Speed Booster not removing .js render blocking and other related issue

Posted in: Newspaper
Post count: 285

Hi again Nano,
If comment out that lines from td-speed-booster, you can not use that metod.

Post count: 436

Hey nairolf,

Happy to see you again 🙂

Yes, you pointed out correctly, this was the method I have tried previously to find IDs but then what does mean by what Andrei wrote :

“To keep it always activated comment or delete the indicated lines from td-speed-booster.php: http://screencast.com/t/RZLIOPUNdqh Also make sure that you added the correct ids for the resources which intent to move.”

He said to add the correct IDs too after deleting the indicated line. What is he trying to say? How should I add IDs then . Is it something different than what is written here :https://forum.tagdiv.com/how-to-make-the-site-faster/ under point-5 ?

If you have any idea of how it should be done correctly so that I can move all these .JS and .CSS files for my plugins correctly, please share the link of the tutorial.

Also, I am taking your advice ( on lowering the plugin number ) very seriousely.. Three days back, I installed a plugin which helps to host Google Analytics code locally ( https://wordpress.org/plugins/host-analyticsjs-local/ ) but I noticed huge decrement in the number of unique vistors and adsense clicks in last three days. Can it be related ( your comment ) ?

Thank you.

Post count: 285

Hi Nano,
Sorry my mistake, the plugin still work even if you comment out the function “// disable the plugins if there are incompatible plugins” but will not recognize any new .js or .css from another third plugin that are not bundled with theme.

That’s why you have to add manually:

$this->move_style_to_footer_queue('here .css ID');

and

$this->move_js_to_footer('here .js ID');

for each new third plugin.

The ID identification is explained from point 5.2 (link)

  • This reply was modified 9 years by nairolf.
Post count: 285

About that plugin “Complete Analytics Optimization Suite (CAOS)”, I see that using wp_cron() to update (I would not touch that).
Nano, with or without GA script we are talking about milliseconds, (on Google Speed Insights is only 1 point). We are more than 50.000.000 webs that using GA so don’t worry about that

Post count: 436

Hey nairolf,

After referring to your comment and the link provided, finally, I successfully activated the speed booster plugin and successfully moved all .JS files in the footer.

In my previous attempt, I was not able to find the correct CSS and JS ID, but this I found it. Reason?

Just discovered the real issue behind why we usually are not able to find the correct .js and .css id for adding it to the td-speed-booster.php and the issue was: I was copying text from the wrong location.

Like me, We all usually copy the “Registered .JS and Registered .CSS code” that appear on the top of the WordPress admin page where we have just added the “code” in functions.php code.

Actually, it displays only those .CSS and .JS codes that loads under WordPress Admin Dashboard panel. To find the actual codes, you must visit either your homepage or any post and then copy the “Registered .JS and Registered .CSS ” file into a text.

But in the case of CSS files, Google Pagespeed still showing various .CSS files


https://domain.com/…in/public/css/facebook-login.css?ver=7.3
https://fonts.googleapis.com/…0,700|Amiri:400,700|Lora:400,700&ver=7.3
https://fonts.googleapis.com/…italic,700,900,500italic,400,300&ver=7.3
https://domain.com/…r/assets/css/js_composer.min.css?ver=7.3
https://domain.com/…ntent/themes/Newspaper/style.css?ver=7.3

Though when I check the “View Source” of my post on Google Chrome, I can see these CSS moving from top to footer ( checked with and without adding the code and noticed the difference) , it’s just that it’s not appearing on Google Pagespeed result. Of course, I cleared all kind of Cache ( Super Cache+ Cloudflare) before checking it, but it’s not reflecting on Google Pagespeed result.

Only one .JS file still appears o some of the post, ie:


http://domain.com/wp-content/plugins/akismet/_inc/form.js

Do you know ID for Akismet so that I can attempt to move it too?

One more important thing- Under some thread, somebody mentioned to search for CSS ID using “View Source” page on Google Chrome but the ID that appears on this page like :


<link rel='stylesheet' id='facebook-login-css'  href='http://domain.com/wp-content/plugins/wp-facebook-login/public/css/facebook-login.css' type='text/css' media='all' />
<link rel='stylesheet' id='google-fonts-style-css'  href='http://fonts.googleapis.com/css?

These IDs contain “-css” at the end but it doesn’t work . Actually ID as found using this method ( Point 5.2) , doesn’t contain -css in the ID and it works well.

So, one should use ‘google-fonts-style’ as CSS ID not ‘google-fonts-style-css’

Can you tell me why it’snot displaying on Google Pagespeed? Is there something else that I need to look on?

Thank you.

PS: I am planning to remove https://wordpress.org/plugins/host-analyticsjs-local/ plugin. Don’t know if it’s the reason behind low traffic

  • This reply was modified 9 years by Nano.
Post count: 285

Hi Nano,

I made a test with Google PSI (with your web) and throws 65/89

You have 5 .css resources that produce an render blocking, 4 of them become from default theme:
– … /facebook-login.css…
– /js_composer.min.css…
– /css?family=Roboto…..
– css?family=Radley….

and this one became from a third plugin: /facebook-login.css

You are using some rules in functions.php that remove query strings from static resources or some plugin that remove them???

I ask you because I see that all other resource are without query strings, and this 5 problematic have them.

Post count: 436

Perhaps yes. I am using following optimisation code created by Chris in functions.php


/** CUSTOM OPTIM CODE : by Christopher Simmons - REV 8.17.16 */

// Remove jQuery Migrate Script from header and Load jQuery from Google API
function simmonsbunny_remove_jquery_migrate_load_google_hosted_jquery() {
	if (!is_admin()) {
		wp_deregister_script('jquery');
		wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js', false, null);
		wp_enqueue_script('jquery');
	}
}
add_action('init', 'simmonsbunny_remove_jquery_migrate_load_google_hosted_jquery');
/** functions for headcleaner */
function rm_generator_filter() { return ''; }
add_filter('the_generator', 'rm_generator_filter');

remove_action('wp_head','wlwmanifest_link');
remove_action('wp_head','rsd_link');
remove_action('wp_head','feed_links', 2);
remove_action('wp_head','feed_links_extra', 3);
remove_action('wp_head','start_post_rel_link', 10, 0);
remove_action('wp_head','adjacent_posts_rel_link_wp_head', 10, 0);
remove_action('wp_head','print_emoji_detection_script',7);
remove_action('wp_print_styles','print_emoji_styles');

function remove_cssjs_ver( $src ) {
 if( strpos( $src, '?ver=' ) )
	 $src = remove_query_arg( 'ver', $src );
 return $src;
}
add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 );
add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 );

function remove_pingback_url( $output, $show ) {
  if ( $show == 'pingback_url' ) $output = '';
  return $output;
}
add_filter( 'bloginfo_url', 'remove_pingback_url', 10, 2 );

/** functions for security */
function no_errors_please(){
return 'You appear to be up to no good. Your IP logged and will be blocked.';
}
add_filter( 'login_errors', 'no_errors_please' );

function disable_reset_lost_password()
 {
   return false;
 }
add_filter( 'allow_password_reset', 'disable_reset_lost_password');

function remove_lost_your_password($text)
  {
    return str_replace( array('Lost your password?', 'Lost your password'), '', trim($text, '?') );
  }
 add_filter( 'gettext', 'remove_lost_your_password'  );

add_filter( 'send_email_change_email', '__return_false' );

/** functions for admin bar */
function mytheme_admin_bar_render() {
  	global $wp_admin_bar;
  	$wp_admin_bar->remove_menu('wpseo-menu');
  }
 add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );
 add_filter( 'wpseo_use_page_analysis', '__return_false' );

function my_custom_css() {
     echo '<style>
          .misc-pub-section.yoast-seo-score.content-score { display: none; }
          .misc-pub-section.yoast-seo-score.keyword-score { display: none; }
     </style>';
}
add_action( 'admin_head', 'my_custom_css' );

function dequeue_yoast_css() {
  wp_dequeue_style('yoast-seo-adminbar');
  wp_deregister_style('yoast-seo-adminbar');
}
add_action('wp_enqueue_scripts','dequeue_yoast_css');

/*remove embeds */
function disable_embeds_init() {
remove_action('rest_api_init', 'wp_oembed_register_route');
remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10);
remove_action('wp_head', 'wp_oembed_add_discovery_links');
remove_action('wp_head', 'wp_oembed_add_host_js');
}
add_action('init', 'disable_embeds_init', 9999);

function project_dequeue_unnecessary_scripts() {
wp_dequeue_script( 'comment-reply' );
wp_deregister_script( 'comment-reply' );
}
add_action( 'wp_print_scripts', 'project_dequeue_unnecessary_scripts',100 );

// Remove comment-reply.min.js from footer
function chrisbunny_clean_header_hook(){
wp_deregister_script( 'comment-reply' );
}
add_action('init','chrisbunny_clean_header_hook');

/** End Christopher's magic bunny code; Copr. (c) 2013-2016 CLS */

But it’s a good thing. right? but why are we still having query strings under these CSS files? Should I not remove query starings using codes in functions.php? How can I remove quesries from these internal ( and one eternal files too )?

What should I do to resolve this issue? Can you suggest something?

Thank you

  • This reply was modified 9 years by Nano.
Post count: 285

Hi Nano,

If you don’t know what are doing every line in particular, don’t use it!, someday you are going to break your web. (you are using some code that are for Newsmag theme!!!)

I tried to remove that querys strings but not working on my local, maybe tagDiv forcing to be not blotted.

I’m afraid that you have to wait until Monday for an expert solution

Post count: 9544

Note – if using a caching plugin or external service, they “might” be adding query strings to things to control caching. I remove query strings so things can be cached. But some other plugins can add them back to disable caching or modify how css and js are cached.

In my example code, on all my sites regardless of theme — not using any external optimization system / CDN, or caching plugin — it does remove the query strings ….

Also note all my optimizations started with newspaper then moved to newsmag and are theme independent as they impact how WordPress works, not the “theme,” unless something specifically says “/* newsmag fix*/” or similar. 🙂

Post count: 285

Hi @Chris, at least on Newspaper 7.4, is impossible to remove the query string with conventional functions for all resources.
Remain untouched: fonts, js_composer.min.css & the main style.css

Post count: 9544

Note if you’re using the speed booster framework plugin, that might be issue; I don’t anymore.

Also note “some” plugins will add the query from their own hook into the enqueue, which can over-ride that function if loaded “later.” I ran into this with the WP YouTube Lyte plugin that snuck in the remove query thing at tail end of functions from itself (easy to hack the plugin to remove that; or de-enqueue the js, then manually add to the footer… )

Helps if you explore in the WordPress docs what some of this stuff does … note the numbers there: (10,2) ? You might need to adjust that ’10’ to “when” your function loads in relation to everything else.

Should also be self evident won’t work in child theme which is dumb CSS redirect to begin with.

$priority
(int) (Optional) Used to specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
Default value: 10

So, in some cases depending on what other shenanigans you have going on, you might have to change the ’10’ to something like ’99’ — to load after everything else and thus actually affect the elements.

e.g.,

function project_dequeue_unnecessary_scripts() {
wp_dequeue_script( 'comment-reply' );
wp_deregister_script( 'comment-reply' );
}
add_action( 'wp_print_scripts', 'project_dequeue_unnecessary_scripts',100 );

So, play with that 🙂

ref:
https://developer.wordpress.org/reference/functions/add_filter/

  • This reply was modified 9 years by simchris.
Post count: 285

Hi again @Chris,
It does not affect me, I tried to help @nano2408 but thank you anyway!

I will put again his last topic because Nano will be confused and tagDiv Staff will not answer his question.
—————————————————————————————————-

Hey Andrei,

I will try everything you wrote above but first let me quickly ask and tell you few things ( Else I have to wait till monday 🙂 )

I have already commented out the code you mentioned here few days back : http://screencast.com/t/RZLIOPUNdqh and under system status it says it’s active “https://i.snag.gy/QFe4y5.jpg” . I haven’t yet changed or modifed any IDs here http://screencast.com/t/uCFJxcIAlu . Is it not working because of that ? Though I can see “TD spped booster ” is mentioned under the “View source code” of my homepage or any page on “Google Chrome”

Actually I dont know how I should do it correctly .Once I had tried by getting the ID using debugging but couldn’t see find appripriate code for plugins like Facebook login and YT subscribe. Can you please tell me ( or give me tutorial link ) for how it do it correctly.

I have also sent you a mail with login credentials too check whatever you wish to.

Thank you very much for all your assistance. 🙂

PS: Excusme for any mistake in this mail. I am trying to make it fast so that you can read it today 🙂

Post count: 436

Hey Chris and nairolf,

It was midnight here and I slept so, couldn’t reply to both of you. Sorry 🙁
I am thankful to nairolf for putting efforts in trying to help me and give me the right direction. I was finally able to make speedbooster working by his help yesterday ( and also disabled one 301-redirection plugin by adding few codes in functions.php because of his motivation to use fewer plugins 🙂 )

Chris is my old fav and his detailed ( and many times witty! 🙂 ) tutorial has helped me a lot to optimize my website in the past.

Anyways, on this point,

I am not sure which codes under Chris’s codes are effecting the Query strings and should I try to change “10 to “101 or max” under this code:


function remove_cssjs_ver( $src ) {
 if( strpos( $src, '?ver=' ) )
	 $src = remove_query_arg( 'ver', $src );
 return $src;
}
add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 );
add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 );

or any other?

I also tried to add one code suggested by KEYCDN here: https://www.keycdn.com/support/remove-query-strings-from-static-resources/ Code is:


function _remove_script_version( $src ){
$parts = explode( '?ver', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );

It didn’t work either .. perhaps for the same reason why Chri’s code didn’t work. May be I should try changing the number 15 to 200 or something?

For nairolf’s suspicion , I checked all other related plugins to see if any function is forcing the query strings behavior that we set in functions.php but couldn’t find anything. I am using itheme security plugin and here I have checked an option which says ” Replace jQuery version with safe version” ( see here: https://i.snag.gy/4SKTg3.jpg ) Previously my Jquery version was 1.12.4 or something but now it’s showing 1.11.1 . Just informing you if it’s the reason behind something.

Other thing I noticed under Yoast SEO, where I have checked “Remove the ?replytocom variables. ” option. Though it serves a different purpose but somehow related to these query thing.

Nairolf said somewhere above that “at least on Newspaper 7.4, is impossible to remove the query string with conventional functions for all resources.”

Then how did you finally removed these strings Nairolf or you didn’t ?

Can’t we move these CSS even with these query strings? And more immportantly, one very important point which you both missed from my previous comment that, after doing required modifications to speedbooster.php, I can actually see that Style.css, fonts and facbook login CSS etc have moved to footer ( Checked “View Source” page of my post on Google chrome) and when I removed JS modifications from speedbooster.php, I saw it coming up on the “view source code”

If sppedbooster were not working with these CSS files, why it would have moved these files from top to footer. The main question is “why it still appears on Google Pagespeed score? ”

Or perhaps it is appearing GPS because GPS is suggesting to remove these query strings and not raising any flag over whether it has been moved to footer or not?

PS: I can understand that tt can be really big tough to deal with a non-progrmmer like me but let me assure you that I do things carefully and I can be instructed very well 🙂

Thank you.

  • This reply was modified 9 years by Nano.
Post count: 6535

Hi

Glad you have manged to sort this out in the end and you have successfully moved the scripts to page’s bottom.
I’ve checked your site again with google page speed tool and the render blocking resources are reported only for mobile devices, even if they are loaded in footer: http://screencast.com/t/yYwtOR38Chttp://screencast.com/t/EjNAHbMBXWG2
Google is very restrictive when it comes about mobile page speed and some things may be interpreted different then for desktop. The Speed Booster plugin does its job and moves those scripts at page’s bottom but it can’t change how google generate the reports. We know about this situation and indeed it’s very strange but we can’t do much about it. The theme and plugins control only page’s html, not google’s algorithm in page speed regard.

Thanks!

Post count: 436

I get it and I hope there is nothing much we can do for it now No matter what plugin or code we use.

Thank you very much Andrei.

Post count: 9544

Also…
as noted in couple of my optimization threads the only way to remove ‘render blocking’ resources for mobile is to actually move the style.css to footer, de-enqueue it from header, and then manually insert the critical CSS in the header.php file manually (use a critical css generator to do this task). This is how I do it.

That is the broad stroke, but something you can explore on your own time. 🙂

Post count: 436

Thank you Chris,
I will surely try to learn the steps that you has suggested above. I hope I have already moved the style.css to footer using speedbooster plugin ( or does actually moving mean something else?) and have probably de-enqueued from header using your code in fucntions.php . The only thing left is manually put crticial CSS in header.php using tools like https://jonassebastianohlsson.com/criticalpathcssgenerator/ . I am unaware of the steps to do so for now. But will surely learn from somewhere.

Thank you very much again 🙂

Post count: 436

And by the Andrei,
You missed one very important point, you checked the homepage but usually, Google or real people visit individual homepage quite often. And on the individual posts, the same .js and .css file ( One Akismet .js files and other 5 css file 2 from Google API and 3 from a tomatoheart plugin VC and style.CSS .

Have a look at the Google Pagespeed Insight for one of the post : http://tomatoheart.com/webjockey/facts-about-bb-ki-vines-bhuvan-bam/ at https://developers.google.com/speed/pagespeed/insights/?url=tomatoheart.com%2Fwebjockey%2Ffacts-about-bb-ki-vines-bhuvan-bam%2F&tab=desktop

Here, mobile and desktop score is almost same: 66/68 ( Snapshot here: https://i.snag.gy/GEvA1z.jpg )

Render blocking Codes from Desktop are:


Remove render-blocking JavaScript:
http://domain.com/wp-content/plugins/akismet/_inc/form.js
Optimize CSS Delivery of the following:
http://domain.com/…in/public/css/facebook-login.css?ver=7.3
http://fonts.googleapis.com/…0,700|Amiri:400,700|Lora:400,700&ver=7.3
http://fonts.googleapis.com/…italic,700,900,500italic,400,300&ver=7.3
http:/domain.com/…r/assets/css/js_composer.min.css?ver=7.3
http://domain.com/…ntent/themes/Newspaper/style.css?ver=7.3

You can check it for any posts of my website and you will find the same thing. SO, the issue is not only with Mobile version.
You may want to look at it again.

  • This reply was modified 9 years by Nano.
Post count: 6535

Hi

Resources reported by google are actually loaded in page’s footer, check this screen: http://screencast.com/t/SFq3fIF6rBXf I am not sure why they are interpreted as rendering blocking resources but this is not anymore a theme related issue or a culprit of Speed Booster plugin.

Thanks!

Post count: 436

Yes. That actually are loaded in footer but probably having query strings at the end might be making it consider to optimise further. Can we remove the version numbers that appears after these CSS names?

Thank you.

Post count: 6535

Hi

Yes it is possible with some custom code, check this link for more details in this regard: https://forum.tagdiv.com/topic/query-string/
Thanks!

Viewing 21 posts - 26 through 46 (of 46 total)
The forum ‘Newspaper’ is closed to new topics and replies.