Removing emoji javascript in wordpress

WordPress adds to its 4.2 build some emoji icons code, which a lot of people using WordPress will find totally unnecessary.

So for those who have no need for emoji’s and the unnecessary impact on server load times and http requests, there are 2 options-

1- Use the disable emoji’s plugin

2 – If you don’t want to use a plugin then add this piece of code to your functions.php file-

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

remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );

Speed up your site by removing query strings

 

By removing query strings from your styles or scripts you can greatly improve your site performance.

Query strings are used in both javascript and style sheets, for example it is one of the methods that a plugin developer will use to render updates. Sometimes though the update is not visible until the cached file expires, and if you are using a CDN then that could take weeks or months.

By removing the query string it avoids you manually clearing your cache, and greatly improves your site performance and speed.

Simply navigate to your function.php and add this code at the bottom (don’t forget to do a backup of function.php, just in case)

 

function remaintenance_remove_query_strings( $src ){
    return remove_query_arg( 'ver', $src );
}
 
if ( !is_admin() ) {
    add_filter( 'style_loader_src', 'remaintenance_remove_query_strings', 15 );
    add_filter( 'script_loader_src', 'remaintenance_remove_query_strings', 15 );
}

Make your Website Faster with GZip

 

Gzip is a server side compression which will speed up your website. The speed at which your site loads plays an important factor in your rankings, as Google have publicly stated, they are obsessed with speed, and therefore we need to pay attention if we are serious about climbing the ranks.

There are many ways to speed up your site, from optimising images to clean code, all of which should be done to maximise our page load speeds. To test your site you can use Google’s own page speed insights which will test your site for mobile and desktop while providing you with tips on further optimising your site.

GZip compression not only speeds up your site but is also a good way to save on bandwidth. It is a very simple method to use and the results are fantastic.

To use this method, you just need to answer yes to the following-

1 – My site uses an apache server.
2 – I have or can create an .htaccess file.

Now add the following code to your .htaccess file –

 

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript# Or, compress certain file types by extension:<Files *.html>
SetOutputFilter DEFLATE
</Files>

 

Simple! Enjoy your extra site speed.

Facing the ‘White Screen of Death’

One of the worst situations you can face is seeing your WordPress site and facing a blank screen, even enabling debug mode can sometimes show you nothing.

This situation could be down to various factors, a broken theme or plugin, and/or exhausted memory. Check with your hosting provider to see if the problem stems from there, such as a poorly configured server, if not, here are a few solutions to the situation.

In most cases of the ‘white screen of death’ you will not have access to your WordPress dashboard, so you might have to go in via FTP. You can do this by navigating to wp-content/themes or wp-content/plugins, using your favourite client.

Broken theme

De-activate your current theme and see if that fixes the problem, if it does, delete or update the theme. You can also check the theme’s ‘function.php’ file to see if there are any coding issues causing the problem.

Broken plugin

Go to your plugins, and de-activate them all, if your website comes back to life then slowly activate one plugin at a time to find the culprit. Update or delete the offending plugin, and maybe let the author know about the problem, the good ones are always glad to help.

Out of memory

You may of reached your memory limit, although the memory is defined by your server, it may be different to your wp-config.php file.

Contact your hosting provider about your memory limit.

To change your wp-config.php file, use a text editor and add this line of code –define(‘WP_MEMORY_LIMIT’, ‘128M’);
This will increase your WordPress site memory to 128mb, but make sure that the memory size is not greater than your server side memory, if not, then you can even increase it to more than 128mb.

Designing a Basic WordPress Theme

If you ever wondered how WordPress themes are put together, this tutorial will run through the very basics of a theme and hopefully wet your appetite in creating your own theme.

Before you start, think about the layout of your new theme, draw it out on a piece of paper if it helps.
For the purpose of this tutorial we are going to split our layout into a very simple grid consisting of a header, main content area, right hand side bar and a footer.

layout

 

 

 

 

 

 

 

1- Using an FTP client or file manager tool, create a sub-folder in the wp-content/themes directory in your WordPress folder and give it a theme name ie “my_theme”.

2- Use a simple text editor like notepad to create the files that relate to the layout for “my_theme”.

We are going to write 5 files to create our layout before uploading our files via FTP to our newly created “my_theme” folder –

header.php (Header area code)
index.php (This is our main area code and will specify where the other files will be allocated)
sidebar.php (Sidebar information)
footer.php (Footer area code)
style.css (This will dictate how our site will look, for example- colours, fonts, spacing etc.)

Here are the files for our layout-

header.php file

<html>
<head>
<title>my theme</title>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>">
</head>
<body>
<div id="wrapper">
<div id="header">
<h1>HEADER</h1>
</div>

 

index.php file

<?php get_header(); ?>
<div id="main">
<div id="content">
<h1>Main Area</h1>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<h4>Posted on <?php the_time('F jS, Y') ?></h4>
<p><?php the_content(__('(more...)')); ?></p>
<hr> <?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>
</div>
<?php get_sidebar(); ?>
</div>
<div id="delimiter">
</div>
<?php get_footer(); ?>

 

sidebar.php

<div id="sidebar">
<h2 ><?php _e('Categories'); ?></h2>
<ul >
<?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?>
</ul>
<h2 ><?php _e('Archives'); ?></h2>
<ul >
<?php wp_get_archives('type=monthly'); ?>
</ul>
</div>

 

footer.php

div id="footer">
<h1>FOOTER</h1>
</div>
</div>
</body>
</html>

 

style.css

body { text-align: center; }
#wrapper { display: block; border: 1px #a3a3a3 solid; width:90%; margin:0px auto; }
#header { border: 1px #a3a3a3 solid; }
#content { width: 70%; border: 1px #a3a3a3 solid; float: left; }
#sidebar { width: 27%; border: 1px #a3a3a3 solid; float: right; }
#delimiter { clear: both; }
#footer { border: 1px #a3a3a3 solid; }
.title { font-size: 12pt; font-family: verdana; font-weight: bold; }

 

These files will give us the basic layout we need. We can tweak the various css rulings to our own liking and upload posts and images to our new blog theme.