Archived topic
defer parsing?
14 replies · Started by Dave on June 16, 2016
Tom, I'm trying to get the speed of my sites down and according to GTMetrix I need to do defer parsing of javascript. I found this: https://premium.wpmudev.org/forums/topic/how-do-i-defer-parsing-of-javascript-to-iprove-performace
Is there somewhere I can put the code from the post here into GP to make it work? In the Simple CSS plugin or in the other part (can't remember but I think the plugin that allows code added before/after posts, pages etc...)
Thanks
Dave
I've used this plugin quite successfully: https://wordpress.org/plugins/async-javascript/
I'm actually writing an article on performance in GP and some tips to get higher scores. Will hopefully have it done soon :)
Great// can't wait to read that!
Any news on the performance article?
Ah yes, here it is: https://generatepress.com/fastest-wordpress-theme
Hello, Tom. Your recommendation regarding .js files is "defer parsing". Would you even recommend to put ALL GP .js files into the footer? And what about the css files, where is the best place for them (header or footer)? I'm using Total Cache (not autoptimize) ... Good Night, Bin!
All GP JS files are added to the footer.
jquery.js is the only file that should appear in the header, this is because it's required for a lot of plugins that might not list it as a dependent (GP does).
CSS should be included in the header, as it should load before the structure of the site in order to avoid any flashing of styles.
Let me know if you need more info :)
OK. So I put these files into the header
/wp-includes/js/jquery/jquery.js?ver=1.12.4
/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1
and all the rest .js goes to the footer (before /body>), right?
Shall I use combine only with Default Blocking OR better with DEFER operation?
Regards, Bin
You shouldn't have to put files anywhere - they should be there by default.
Defer should work just fine for those two files :)
Yes, thats right. But I want to combine these 11 GP .js files in just ONE file by using the minify option of W3 Total Cache. I'm using "Combine only" because they are alrdeady minified (by your great effort!). My question is now, if it's better to set this comined.js file as ASYNCH, DEFER or BLOCKING? Bin
To be honest, I'm not sure. Give each of them a try and test your site on pingdom to see which gets the best results :)
Sorry, and what about:
wp-includes/js/wp-embed.min.js?ver=4.6.1
Header or footer?
Probably footer - that's another core WP file.
TOM, you are the best!
Bin
Glad I could help! :)