Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I got a custom wordpress theme from a developer but he isn't responding to me anymore. Basically my homepage takes ages to load which causes all the elements on the homepage not function until the javascript loads.

I believe the problem lies within this script which is found in the functions.php file, I'm running wordpress 3.5.

Can anyone spot some glaring issues, please help a lost soul.

function theme_init_theme() {
    # Enqueue jQuery

    if (is_admin()) { /* Front end scripts and styles won't be included in admin area */
        wp_enqueue_style('theme-custom-admin', get_bloginfo('stylesheet_directory') . '/css/admin.css', array(), '1.0');
    # Enqueue Custom Scripts
    # @wp_enqueue_script attributes -- id, location, dependancies, version
    //wp_enqueue_script('custom-script', get_bloginfo('stylesheet_directory') . '/js/custom-script.js', array('jquery'), '1.0');
    wp_enqueue_script('jquery-flexslider', get_bloginfo('stylesheet_directory') . '/js/jquery.flexslider-min.js', array('jquery'));
    wp_enqueue_script('jquery-cookie', get_bloginfo('stylesheet_directory') . '/js/jquery.cookie.js', array('jquery'));
    wp_enqueue_script('jquery-colorbox', get_bloginfo('stylesheet_directory') . '/js/jquery.colorbox-min.js', array('jquery'), '1.0');
    wp_enqueue_script('jquery-functions', get_bloginfo('stylesheet_directory') . '/js/functions.js', array('jquery', 'jquery-flexslider', 'jquery-cookie'));
    wp_enqueue_style('googlefont-open-sans', 'http://fonts.googleapis.com/css?family=Open+Sans:400,800italic,800,700italic,700,600italic,600,400italic,300italic,300');
    wp_enqueue_style('googlefont-merriweather', 'http://fonts.googleapis.com/css?family=Merriweather:400,900,700,300');
    wp_enqueue_style('colorbox', get_bloginfo('stylesheet_directory') . '/css/colorbox.css', array(), '1.0', 'all');
add_action('init', 'theme_init_theme');
add_action('after_setup_theme', 'theme_setup_theme');
share|improve this question
There is nothing inherently wrong with the function you posted. Might be a server issue, might be something else in the theme, might not be a single reason and just that the theme is heavy. You'll find a good number of answers on how to speed up pageload in WP here. I feel this is too localized an issue. Sorry. –  Johannes Pille Aug 1 '13 at 16:05

1 Answer 1

I should start by saying that there doesn't appear to be anything in that code that is home page specific so the fact that you see this only on the home page may mean that the problem is elsewhere. However...

You are hooked to the wrong hook. You should have that hooked to wp_enqueue_scripts

add_action('wp_enqueue_scripts', 'theme_init_theme');

I doubt that is the source of the problem though.

You could probably alleviate some of the trouble by loading non-critical scripts in the footer of the page by setting the fifth parameter of wp_enqueue_script()

  get_bloginfo('stylesheet_directory') . '/js/jquery.flexslider-min.js',

I can't say for sure since you didn't post a working URL but my guess is that the biggest holdup is the fonts. You are loading two fonts in several different sizes and styles. That is quite a bit of bandwidth. I would consider reducing or eliminating the font loading. You can comment the font lines and run an experiment to see if the guess is right.

Posting a working URL will allow for better analysis.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.