@nano2408
Hi, no idea; I don’t use any mobile theme plugins; preferring to rely on optimized responsive design and AMP support, etc.
Complex question, you may wish to post a new topic as this isn’t really related to my optimization thread, specifically. 🙂
(( I don’t work here. ))
Sorry… been busy rescuing some sites which were borked due to improper backups (sigh) from Aug 5 web server crash (damn you Softlayer/IBM!)….
here was the updated bunny code which took out the renaming of the author slug to profile, and fixed the comment removal in footer, and the emojis….
this would go at bottom of functions file … if you want; only tested with Newsmag 3.1 and other themes I use (I do have a custom thing we use for e-commerce, and our news portal mothership, but those are super custom things):
=================
/** CUSTOM OPTIM CODE : by Christopher Simmons - REV 11..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');
add_filter( 'jpeg_quality', create_function( '', 'return 50;' ) );
/** 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');
remove_action( 'wp_head', 'wp_resource_hints', 2 );
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);
// 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 */
-
This reply was modified 9 years by
simchris.
Hi Chris S,
I saw that the link
https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js
but to me there is this link:
https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js?ver=1.11.1
It is already in the footer after using the plugin tagDiv Speed Booster
What to do you think ??
Orlando
Well, WordPress 4.6x uses 1.12.4 — so why load two versions ?
I don’t use SpeedBooster, so no advice on that 🙂
I am using the “scripts to footer” plugin for testing, then I just move the stuff once I have critical CSS generated.
Guess that isn’t much of an answer, but it’s all I got.
I am actually working on a ‘plug-in’ right now for all my custom functions.
=========
building my own WP plugin called “[name pending]” to do this:
(1) remove junk from WP headers like versioning, emoji scripts, comments feeds
(2) change default WP image quality for thumbnails for better speed
(3) security fixes to disable poking the built-in password reset and password reset email junk not needed for most businesses;’ disable XMLRPC/pingbacks, etc.
(4) Sitemap shortcode, so one could drop a single line into a page to generate local sitemap of company pages and info
(5) OG tags generator for FB, Pinterest, social
(6) SEO basic headers to drop in keywords, schema, image, meta titles and descriptions based on type of page (without having to use a super bloaty SEO plugin that might actually mess up your site when updated)
(7) Remove /category/ and /tag/ base elements; option to rename /author/ slug to something else like /department/ or /expert/ 🙂
And more … all in ONE plugin which can easily be commented out if client doesn’t want something when developing their site.
I will put this onto the web once it’s done 🙂
(need to add toggles for on/off on things in the admin panel; version 1.0.1 does not have admin panel options)
-
This reply was modified 9 years by
simchris.
You could just remove my version of the code for jquery I suppose;
my version is assuming you are *not* using SpeedBooster 🙂
For example, you could try
a) speedbooster + my functions /without my jquery code
b) ‘scripts to footer’ ( https://wordpress.org/plugins/scripts-to-footerphp/ )
plugin + my functions w/my jquery code
compare results with Newsmag 3.1x ?
-
This reply was modified 9 years by
simchris.
Hi,
likely Feb. ?
I have to get our new corporate website 2017 done for January (working on that right now, oh wait, no I’m not, I’m here!) 😉
Using super lean WordPress home-brew theme, with Bootstrap 3x and avoiding some dumb aspects of WordPress (like, why enqueue css in head, then unenque with function, then manually put in footer .. ? why not just put it in footer to begin with – duh !).
Anyway… for this plugin doing some neat things for our own “corporate site,” like adding the excerpt box for pages, so THAT can be used for SEO elements, and custom field for Facebook image; basically couple of really simple things to not have to load Yoast SEO and ACF to do some really basic things. I don’t use YOAST SEO for anything except the headers META and sitemap, and it’s getting freaky bloated now for just doing that!
Anyway… the idea for plugin is to allow me to add all the stuff I keep doing in one darn plugin so I can stop editing every damn functions.php file !
However, before I can release to public I will need to make some admin panel options, to turn stuff off/on (like maybe you want the stupid emoticons?), and perhaps you want less compression than “50,” so how nice to have an option to set quality factor in a box ? Yeah!
So after 12 years with WordPress, finally snapped on this latest project and said “you know, why don’t I just put all this damn stuff into a plugin?” — anyway, that’s the plan. Doing it for myself, and this will trickle into a free thing others can use.
Peace out!
Chris
Sorry, master.
After adding your code, my blog’s pagespeed & page load time decrease. Please advice me.
https://forum.tagdiv.com/topic/tutorial-chriss-custom-optimizations-for-functions-php-etc/page/7/#post-144368

-
This reply was modified 9 years by
Syams.
Test with Google Pagespeed for “real” score with Google.
Speed cannot decrease by removing things. (note fewer items, smaller size?)
Depending on setup, which presumes an optimized htaccess file also, you may want to load jquery locally, for example with http/2 it may actually be quicker to “bundle” into the packet cache.
Hi Chris S,
you who are a real web professional, how can you fix this problem ???
Delete JavaScript and CSS that block the view in above-the-fold content
Your page has 4 blocking CSS resources. This causes a delay in the page.
It was possible to see about 58% of above-the-fold content of the page without having to wait for the loading of the following resources. Try to postpone or to load asynchronously lock resources or incorporates key parts of these resources directly into the HTML code.
Optimize CSS publication of the following:
https://fonts.googleapis.com/…family=Open+Sans:300,400,600,700&ver=3.2
https://fonts.googleapis.com/…00,700italic,400italic,300italic&ver=3.2
https://www.site.com/…r/assets/css/js_composer.min.css?ver=3.2
https://www.site.com/…content/themes/Newsmag/style.css?ver=3.2
I hope you can help me, Thanks
Orlando
You need to do the things in my thread
a) you need to optimize fonts either by not using Google Fonts, or you need to unhook them per my notes, then manually put the actual CSS in your style.css file at bottom
b) you need to minify the style.css file using my thread info.
c) consider some of the longer winded stuff — which is super advanced; the only way to fully eliminate above the fold issue is to put css in footer, after un-enqueuing it from the header, then use a critical css generator to build the CSS and put into your header.php file.
—
or — you can try to resolve some of that by using the speedbooster plugin.
Note I am only working with Newsmag optimzations now, and no longer use Newspaper.
Also note, that if you get everything else optimized, the ‘above the fold’ isn’t going to kill you in SERPS.
But there is *no* one click solution to fully optimize your site for maximum speed.
Is this compatible with newsmag v3.3? https://forum.tagdiv.com/topic/tutorial-chriss-custom-optimizations-for-functions-php-etc/page/7/#post-144368
Hello
I am no longer updating this thread or posting to forum, but you should be able to use all this stuff with Newsmag, as most of it is common to all WP installs, especially Linux/Apache stuff.
Stuff like editing/moving the fonts are likely still in the same files and locations if you look for them.
Obviously, the way to do any mods is to make backups, then working copy; upload work files with changes, test; if busted, re-upload the backup files. Make backups of changes as you go, so you can ‘roll back’ to any middle version of modified files.
Good luck!
Chris S.
Hi, no longer updating this thread, as I’m now moving to testing optimizations utilizing
a) php 7 with enhancements for code and opcache, even better than php 5.6 (5.4 is a DOG!).
b) https + http/2
We have dedicated server, so a bit different approach than many others here. We do not use CDN as not secure (e.g., Cloudflare), or not any faster for our U.S. client/audience due to our server in Class A datacenter in Texas.
Hi folks
although I’m not updating this thread anymore; note that I have been playing with the system font stack concept a bit more in Fall 2017 — and I covered how to hack the theme for this a page or two back — but have now decided for new project I do want Google fonts for the page text on desktop, Georgia for headers, but I want system font stacks for all mobile … so how to do THAT ?
Fun article I can recommend on this topic — only for those who want to mess with their font setup beyond the theme panel (TagDiv can’t help you with this topic!):
https://css-tricks.com/preventing-the-performance-hit-from-custom-fonts/
-
This reply was modified 8 years by
simchris.
Hi
I know I’m technically ‘not updating this thread’ anymore to concentrate on my adventures with php7 + https + http/2 …
but I only today discovered this awesome ‘ultimate boilerplate’ for setting up a custom wp-config.php file with all the pieces to customize however you need all in place, and then you just remove what you’re not needing. Very very nice.
This came recommended by the official WordPress.org codex/docs, btw:
https://github.com/pixeline/wp-config-supercharged/
