WordPress.org

Ready to get started?Download WordPress

Forums

WP Minify
No files get minified (6 posts)

  1. Riddergraniet
    Member
    Posted 1 year ago #

    I use the preferred way to enqueue scripts, but still only a few CSS files get minified and none of my theme JS files get recognized by WP Minify. Here's how I define my JS files:

    function gholumn_scripts() {
        wp_deregister_script( 'jquery' );
        wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', null, '1.7.2', true);
        wp_enqueue_script( 'jquery' );
    
        wp_enqueue_script( 'google-font-loader', get_template_directory_uri() . '/js/fontloader.js', null, null, false);
        wp_enqueue_script( 'jquery-ui-gholumns', get_template_directory_uri() . '/js/libs/jquery-ui-1.8.18.custom.min.js', array('jquery'), '1.8.18', true);
        wp_enqueue_script( 'jquery-throttle', get_template_directory_uri() . '/js/jquery.throttle.min.js', array('jquery'), null, true);
        wp_enqueue_script( 'gho-coolcolumns', get_template_directory_uri() . '/js/jquery.gho.coolcolumn.js', array('jquery'), null, true);
        wp_enqueue_script( 'gho-coolcontent', get_template_directory_uri() . '/js/jquery.gho.coolcontent.js', array('jquery'), null, true);
        wp_enqueue_script( 'gho-coolcontent-freetext', get_template_directory_uri() . '/js/jquery.gho.coolcontent.freetext.js', array('jquery'), null, true);
        wp_enqueue_script( 'gho-coolcontent-people', get_template_directory_uri() . '/js/jquery.gho.coolcontent.people.js', array('jquery'), null, true);
        wp_enqueue_script( 'gho-permalinkhandler', get_template_directory_uri() . '/js/gho.permalinkhandler.js', array('jquery'), null, true);
        wp_enqueue_script( 'gho-plugins', get_template_directory_uri() . '/js/plugins.js', array('jquery'), null, true);
        wp_enqueue_script( 'gho-script', get_template_directory_uri() . '/js/script.js', array('jquery'), null, true);    
    
    }
    
    add_action('init', 'gholumn_scripts');

    And yes I also tried to remove the $in_footer = true argument with every wp_enqueue_script call but also that didn't help. In fact, that made it worse, as nothing was included anymore when I did that.

    Settings in WP Admin are good: JS, CSS and HTML minification are all on. I tried with and without the option to put it in the footer (although WPM does not recommend footer placement).

    What am I doing wrong?

    http://wordpress.org/extend/plugins/wp-minify/

  2. Kimberly
    Member
    Posted 1 year ago #

    This is a known bug which a few of us addressed and fixed. Check out one of the other comments to find a step-by-step fix.

  3. danielmichel
    Member
    Posted 1 year ago #

    'one of the other'? can you link us?

  4. pha3z
    Member
    Posted 1 year ago #

    I agree with danielmichel. Its generally poor practice to refer to any information online without providing a link to the source. It leaves a lot of people hanging. Some people have very different search techniques than others, and not everyone will find the desired resource quickly.

    Since hundreds if not thousands of users will want to see the source anyway, think of it like Steve Jobs said regarding the very first Apple boot times. He calculated that a 5-second faster boot time when added up for all of the boots and reboots of the millions of computer owners amounted to so many thousand "lives saved" since the numbers got into the thousands of years range with the mass parallelization. Makes sense to me. If you save 10,000 people 10 seconds each, you'ved netted humanity a full 27 hours. LOL

    Now just think. What if its 5 minutes each instead of 10 seconds each!!! 27 hours turns into thirty-three 24-hour days. Thats 20 Weeks of 40-hour work weeks. Why not save them the time?

  5. Cliff Seal
    Member
    Posted 1 year ago #

    I just happened to stumble across this post—I don't know if this will solve your issue with the plugin or not, but you need to update a couple of things in this function.

    First of all, unless you want all of these scripts to be loaded in the admin, you need to be hooking into wp_enqueue_scripts instead of init. In your case:

    add_action('wp_enqueue_scripts', 'gholumn_scripts');

    I think you must've read a non-Codex article (or something outdated) if you think that init is the "preferred way".

    Also, are you registering all these scripts prior to enqueuing them? The only ones you can enqueue without registering are found here: http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_scripts_included_with_WordPress.

  6. Alex Hernandez-Zamudio
    Member
    Posted 7 months ago #

    Sup Folks,

    A simple solution that worked for me WITHOUT tweaking core WP Minify files was to enqueue all my scripts in the header instead of the footer. When you enqueue your files in your functions.php file declare FALSE at the end of the array to force scripts to load in the header.

    ex.
    <?php wp_register_script('modernizer', get_template_directory_uri() . '/js/modernizr.js', 'jquery', '2.6.2', FALSE ); ?>

    Hope that helps.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic