Categories
blog

Add Google Fonts to WordPress.

You can add Google Fonts to your WordPress site in under one minute. One minute to create a unique branding for your WordPress website. Why would you not do it?

Using Google Fonts can give your site a customized look. In addition, fonts loaded from there will be faster than using self-hosted font files. Sometimes self-hosted fonts take the longest time to download by the browser. Fonts loaded from Google’s Content Delivery network (popularly known as CDN) will eliminate requests from your own server and also decrease latency on your server.

To use Google Fonts on your WordPress website, add the following to functions.php in your theme.
Remember to change the font with the font you want to use.


function load_fonts() {
wp_register_style('googleFonts', 'http://fonts.googleapis.com/css?family=font');
wp_enqueue_style( 'googleFonts');
}
add_action('wp_enqueue_scripts', 'load_fonts');

Categories
blog

WordPress function to load jQuery from Google’s CDN.

Loading jQuery using Google’s Content Delivery Network(CDN) will lead to decreased latency, meaning faster load time for your site. Using this method eliminates a request from your server. In some cases the user may already have the exact version of jQuery cached from Google’s CDN, meaning they do not need to download it again. However, if you host jQuery locally from your site, the user must download it, even if it is the same version.

To load jQuery from Google’s CDN, add the following to your functions.php file in your theme.
Remember to change the version of jQuery with the version you want.


function load_jquery() {
if (!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', false, '1.11.1', true);
wp_enqueue_script('jquery');
}
}
add_action('wp_enqueue_scripts', 'load_jquery');