Make your site load faster with code

Hi Guys

I am not looking for more plugins, but I was thinking if there was some html codes you could use to make your site load faster. Maybe some codes to put in the function or config file or something else. Just anything that can improve the load speed, but not plugins, just code.

  • Gabe

    Just anything that can improve the load speed, but not plugins, just code.

    Plugins are code. For example, any code in your functions.php file can be pulled out and put in a separate functions.php file, added to the plugins folder, and activated like a plugin. Along the same lines, any plugin code could be added to your theme's functions.php file and would work the same way (assuming there are no dependencies).

    Functionally, there's really no difference between code that's activated as a plugin or activated as part of your theme's function.php file. Where you get performance issues is poorly written code, extra http requests, unoptimized files (images, js, css), slow server response time, no caching, etc.

    -To combine/minify JS and CSS, you could try AssetMinify or something similar.
    -To make sure images are served quickly you could install Jetpack and use Photon. Just be sure to disable the other modules you're not using. If you don't want to use Jetpack, there are plenty of other CDNs, but most are paid.
    -Upgrade to decent hosting. WP Engine is a good option, but there are plenty of others.
    -Ensure you're using caching of some sort. If you're using WP Engine caching is done automatically, but if you're not try W3 Total Cache or one of the other caching options.
    -Use an optimized, well-built theme. I used StudioPress and the Genesis framework, but there are plenty of other options.

    There are other things you can do, but these are a good foundation. Tools like Pingdom's page speed test, Google PageSpeed Insights, and Webpagetest.org are decent at identifying issues.

    I don't consider myself a hardcore developer, but using the techniques above my homepage loads in around 500ms on average with around 18 http requests and it's in HTML5 with some decent effects (i.e. responsive, persistent header, etc.).

    Hope this helps.

  • faydra_deon

    @sorensen84:

    I provide the following information to another member who was trying to speed up her site. Just ignore the plugin suggestions if you're dead set on not using any more plugins.

    I thought it may help you if I shared with you what my host sent me a few times when they said I needed to make my sites "smaller."

    1) Download and activate WP Super Cache:
    http://wordpress.org/extend/plugins/w3-total-cache/ using the recommended settings here: https://support.hostgator.com/articles/specialized-help/technical/wordpress/wp-super-cache-plugin
    2) Download and activate WP Smush.it:
    http://wordpress.org/extend/plugins/wp-smushit/
    This plugin will optimize every image upload henceforth.
    3) Don't use ETags unless customer are taking advantage of it. How to http://www.tipsandtricks-hq.com/how-to-add-far-future-expires-headers-to-your-wordpress-site-1533
    4) Use external scripts. Instead of placing tons of code in your header.php file, use external scripts. This allows the browser to cache the script so it won't have to read it for every other page.
    5) Keep page sizes less than 100kb. Do not use too many unnecessary images and video on a page. Always compress the images appropriately.
    6) Disable wp-cron. Insert in wp-config.php this command:
    define('DISABLE_WP_CRON', true);
    7) Optimize WordPress database. For that customer should use one of three plugin:
    WP-DBManager - http://wordpress.org/extend/plugins/wp-dbmanager/
    WP-Optimize - http://wordpress.org/extend/plugins/wp-optimize/
    WP-Clean Fix - http://wordpress.org/extend/plugins/wp-cleanfix/
    8) Reduce requests from bots. Example of robots.txt for CMS WordPress:
    User-agent: *
    Crawl-delay: 10
    Disallow: /cgi-bin/
    Disallow: /wp-login.php
    Disallow: /wp-register.php
    Disallow: /xmlrpc.php
    Disallow: /wp-admin/
    Disallow: /wp-includes/
    Disallow: /wp-content/plugins/
    Disallow: /wp-content/themes/

    I copied and pasted exactly what they sent me, so some of this may not apply to you, but it'll at least give you some ideas of what else you can do to optimize your site.

    Another thing that might be happening is that someone may be trying to hack into your site. There's a plugin called BruteProtect that will shield you from that. Here's the link: http://wordpress.org/plugins/bruteprotect/ This was happening on a site I have on hosting with IX Webhosting.

    Also, here's a link to Vladimir Prelovac's WordPress Optimization Bible: http://www.prelovac.com/vladimir/wordpress-optimization-guide. It may also help, although it may duplicate some of the information that I copied and pasted right above.

    I hope something in that helps out. Also, keep in mind that it might be the actual plugins you're using that is causing your site to run slowly. Poorly coded plugins could be an issue, so it's possible that switching to another plugin that does the same thing would speed up your site. For example, some sources say All In One SEO plugin will slow down your site whereas WordPress SEO by Yoast doesn't do this. That's just an example. I don't know if that's the case with that particular plugin.

    Faydra...

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.