More Speed Improvements Sharing For functions.php

Posted in: Newsmag
Post count: 89

Hi,

Just thought i would contribute some of things i have found boosted my site speed, I used Chris’s code along with these. These obviously all go in your functions.php file.

1. Remove the wp emoji file that is automatically included in wp 4.2 (don’t worry about this if you have earlier version)
2. If you use contact form 7 plugin it will load it’s assets on all pages/posts (you should use this code if you don’t have a contact form in the footer or on every page) ***YOU WILL NEED TO ADD/CHANGE THIS LINE: if ( ! is_page( ‘contact-us’, ‘another-url’ ) ) { // where contact-us = page URL
3. If you don’t use the standard wordpress comment system and instead use Facebook Comments, Disqus, Livefyre, or nothing.. you can remove comment-reply.min.js (I found this code on crunchify)

//REMOVE WP EMOJI
remove_action(‘wp_head’, ‘print_emoji_detection_script’, 7);
remove_action(‘wp_print_styles’, ‘print_emoji_styles’);

// Deregister Contact Form 7 CSS styles
add_action( ‘wp_print_styles’, ‘aa_deregister_styles’, 100 );
function aa_deregister_styles() {
if ( ! is_page( ‘contact-us’ ) ) {
wp_deregister_style( ‘contact-form-7’ );
}
}
// Deregister Contact Form 7 JavaScript files on all pages without a form
add_action( ‘wp_print_scripts’, ‘aa_deregister_javascript’, 100 );
function aa_deregister_javascript() {
if ( ! is_page( ‘contact-us’ ) ) {
wp_deregister_script( ‘contact-form-7’ );
}
}

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

Thanks

Post count: 89

I also have a question Not sure if anybody will know the answer.

I’m running an image heavy site, at the moment i am uploading all images to my sever and am using Amazon Cloudfront as the CDN for my images.

But i was thinking how do sites like buzzfeed do it. Do they upload all images to their server or do they have an external cloud storage system like amazon S3? Also there a way to have an upload image system like imgur.com, where you can just add the URL of the image and boom it’s stored on your server?

Post count: 6600

Hi,

Thanks for sharing the speed infos.
Seems that you’re right on the amazon s3 system: http://screencast.com/t/i5ua9Q8XSMqR
Maybe this could help: http://wordpress.stackexchange.com/questions/158491/is-it-possible-set-a-featured-image-with-external-image-url
Please note that I haven’t tested it so you might not work.

Thanks

Post count: 9544

@gfran5

hey … very cool, thanks!

At some point I need to revisit the thread I had with Radu back on v1.4 or was it 1.5 on removing some of the “add once” calls in the theme booster functions file, such as removing calls to woocommerce, bb forum, etc., if not actually using those to eliminate the CSS even being called at all.

On my to do list 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.