Back to Top

BWP Minify Released!

Previous Post:

BWP Minify Released!

Support for this plugin has been moved to the BWP Community!

Hello my beloved visitors! BWP Minify, my 4th plugin, is now available for everyone. This plugin relies on WordPress’s enqueueing system rather than the output buffer to minify your JS and CSS files. Your website/blog will now load much faster!

Features at a glance

  • Uses the enqueueing system of WordPress which improves compatibility with other plugins and themes
  • Allows you to customize all minify strings
  • Offers various way to add a cache buster to your minify string
  • Gives you total control over how this plugin minifies your scripts
  • Supports script localization (wp_localize_script())
  • Supports RTL stylesheets
  • Supports media-specific stylesheets (e.g. ‘screen’, ‘print’, etc.)
  • Supports conditional stylesheets (e.g. <!--[if lt IE 7]>)
  • Provides hooks for further customization
  • WordPress Multi-site compatible (not tested with WPMU)

The current formal version is 1.0.0 (bug fix release: 1.0.8) and you can find detailed information as well as download links on this page: wordpress-plugins/bwp-minify/

Please report any bugs by posting a comment below. Thank you!

Take Social Sharing to
the Next Level with Monarch!

Take Social Sharing to the Next Level with Monarch!
Print Article Trackback Trackback to this Article   Subscribe to Comments RSS Subscribe to Comments RSS

86 Opinions for BWP Minify Released! (52 Trackbacks)

  1. User's Gravatar
    1
    Andy August 11, 2011 at 11:21 pm – Permalink

    Hi there,

    Great plugin, I integrated it into a theme I am building, was really easy. My only concern is that when enabled it will always pack and minify all files that are included using wp_enqueue_style.

    What I would like to know is if its possible and how to go about making it only work on files in a certain directory. That way I could add an option that limits the functionality to the themes files only. Then I could add an option in the theme or the plugin that the user can decide whether to only pack the themes files called in the theme, or all files on their site from the theme and all plugins.

    Thanks,

    Andy

    • User's Gravatar
      2
      OddOneOut August 12, 2011 at 11:40 am – Permalink

      Hi Andy,

      Currently you will only be able to ignore certain CSS files by using some filters, as listed here: http://betterwp.net/wordpress-plugins/bwp-minify/#references.

      If you want, in the next version, we can have something like this:
      – A hook your theme can filter.
      – Your filter will return a list of handles that should be minified by BWP Minify, if return false or ‘all’ then my plugin will just minify anything it can find.

      Please tell me if that works for you.

  2. User's Gravatar
    3
    Andy August 12, 2011 at 5:23 pm – Permalink

    Hi,

    Thanks for your reply! Yeah, I saw the ignore filter, but its kind of the opposite of what I need. I understand that it is ideal as it is now as a standalone plugin. If a user decides to install and activate the plugin, then they chose to concatenate and minify all css and js files added using wp_enqueue_style()

    Having it built into the theme, is a little different, because as a theme developer, I don’t want to assume they want ALL files to be packed and minified, just because they are using the theme. It’s better if all the themes js and css files are minified but all other files are untouched… unless otherwise specified.

    Your proposed solution sounds good, but I am not sure exactly how you see it working. Can you provide a dummy example of how the code to add the files will look once completed.

    This is a simplified example of how I am currently adding the css files.

    function add_slate_css() {
    $css_path = get_template_directory_uri() . ‘/library/css/’;
    wp_enqueue_style(‘reset’, $css_path . ‘reset.css’);
    wp_enqueue_style(‘skeleton’, $css_path . ‘skeleton.css’);
    wp_enqueue_style(‘layout’, $css_path . ‘layout.css’);
    }
    add_action(‘wp_print_styles’, ‘add_slate_css’);

    How would it work if I wanted to add these using the new hook that the theme can filter?

    Thanks again for your prompt response 🙂

    • User's Gravatar
      4
      OddOneOut August 12, 2011 at 8:28 pm – Permalink

      Something like this I think:

      add_filter('bwp_minify_allowed_handles', 'your_filter');
      function your_filter()
      {
      	// If the user choose to minify css files from the theme only
      	if ($theme_only)
      		return array('reset', 'skeleton', 'layout');
      	return 'all';
      }
      

      Easy as pie, eh?

      Just curious, how did you integrate my plugin?

      • User's Gravatar
        5
        Andy August 12, 2011 at 9:07 pm – Permalink

        Ok, that looks perfect. Would I still enqueue them as normal and then add this filter?

        Integrating it as part of the theme was pretty straight forward. All I did was include the main file in my themes functions.php.

        include_once('library/includes/bwp-minify/bwp-minify.php');

        After that I could see the menu in settings and could use it as normal. I wanted to keep using your options instead of building new ones. So users will still use the same settings page.

        The only other thing I did was change the base path for the option “input_minurl” from the plugin path to the themes path in the “class-bwp-minify.php” file. This way it would always be the correct path for how its implemented.

        Thanks for all your help 🙂

        • User's Gravatar
          6
          OddOneOut August 13, 2011 at 12:20 am – Permalink

          Hi,

          Would I still enqueue them as normal and then add this filter?

          Yup!

          The only other thing I did was change the base path for the option “input_minurl” from the plugin path to the themes path in the “class-bwp-minify.php” file. This way it would always be the correct path for how its implemented.

          In the next version I will put a hook where that option is first set so you can change it without modifying any code ;).

          Anyway, good luck with the theme!

          • User's Gravatar
            7
            Andy August 23, 2011 at 6:52 pm – Permalink

            That’s perfect.. thanks 🙂

          • User's Gravatar
            8
            Andy August 24, 2011 at 1:53 am – Permalink

            I only just noticed you released v 1.0.5 yesterday.. 🙂

            May I ask how I would use the “bwp_minify_min_dir()” filter to change the minify url. I could not get it to work.

            Thanks,

          • User's Gravatar
            9
            OddOneOut August 24, 2011 at 1:45 pm – Permalink

            The min dir is saved to the database once you visit the admin page, so you can only use the filter when you first install BWP Minify on a new site.

            If you would like to test it, find bwp_minify_general in your database and delete it, the plugin will recreate the options with the min dir you pass to the filter ;).

          • User's Gravatar
            10
            Andy August 24, 2011 at 4:23 pm – Permalink

            Thanks for your reply, that is what I was doing. I was deleting the bwp_minify_general from the DB each time but it was still not picking up the new url.

            This is the code I used

            add_filter('bwp_minify_min_dir', 'set_bwp_min_directory');
            function set_bwp_min_directory()
            {
            	return 'hxxp://wp.dev/wp-content/themes/slate/library/includes/bwp-minify/';
            }
            

            I tried a few variations as well, please can you clarify what I may be missing.

          • User's Gravatar
            11
            OddOneOut August 25, 2011 at 2:57 pm – Permalink

            Sorry Andy, my bad. The current hook doesn’t allow you to apply any filter from theme (from other plugins is ok), I will release a fix next week, a long with filter for scripts, as requested by you ;).

  3. User's Gravatar
    12
    botox glasgow August 19, 2011 at 8:06 pm – Permalink

    I am totally lost with it all! info overload!! 🙂

  4. User's Gravatar
    13
    Bob August 21, 2011 at 12:50 am – Permalink

    Hi,

    BWP Minify currently doesn’t work with the plugin Easy Fancybox. I have added jquery.fancybox to the “Scripts to be minified and then printed separately” section. It makes the image load as a file instead of go to the bottom of the page. Can you please tell me what to add as an exception?

    Example: http://www.putdispenserhere.com/ipv6-tunnel-setup-guide/

    Many thanks 😀

    • User's Gravatar
      14
      OddOneOut August 21, 2011 at 10:21 am – Permalink

      I will release a new version today and I will try to add support for Easy Fancybox, stay tuned!

      • User's Gravatar
        15
        Bob August 21, 2011 at 12:55 pm – Permalink

        Thank you very much for being proactive! A request for the future would be to whitelist specific files to excluded.

        • User's Gravatar
          16
          OddOneOut August 21, 2011 at 1:43 pm – Permalink

          Hi Bob,

          A request for the future would be to whitelist specific files to excluded.

          Could you please elaborate? We already have “Scripts to be minified and then printed separately” section?

          • User's Gravatar
            17
            Bob August 21, 2011 at 10:41 pm – Permalink

            I mean you would put the file path and name like WP Minify to have it excluded. I have spent a long time trying to find the plugin handle unfortunately.

        • User's Gravatar
          18
          Andy August 23, 2011 at 6:51 pm – Permalink

          This is already included in the plugin options. You can exclude any scripts by adding the handle in the input “Scripts to be ignored (not minified)” and they will be excluded from the minified and packed version thats created.

          eg: http://www.joomlajunkie.com/images/snaps/exclude.png

          You can also do this with css files using a filter.

          add_filter('bwp_minify_style_ignore', 'exclude_my_css');
          
          function exclude_my_css($excluded)
          {
          	$excluded = array('reset', 'skeleton');
          	return $excluded;
          }

          @OddOneOut

          Is there a filter for doing the same but for scripts?

          • User's Gravatar
            19
            OddOneOut August 24, 2011 at 12:14 am – Permalink

            Actually he requested the ability to input the filenames instead of the handles, because it’s very easy to look at the source code to find the filenames. Maybe BWP Minify should allow both.

            Is there a filter for doing the same but for scripts?

            You should have requested that earlier, I will include more filters in 1.0.6, which is expected to be released next week.

          • User's Gravatar
            20
            Andy August 24, 2011 at 1:02 am – Permalink

            Ok, I see. I missed that he wanted to use the filename. I generally keep the handle and file name the same, just the file has .js on the end. This makes it easy to remember.

            I look forward to the updates. Thanks a lot!

  5. User's Gravatar
    21
    Bob August 24, 2011 at 5:49 am – Permalink

    Thank you very very much for fixing the plugin to have Easy Fancybox compatibility. Thank you for making it an even better plugin 😀

    You have a coffee coming your way 😀

  6. User's Gravatar
    22
    akash August 31, 2011 at 11:29 am – Permalink

    BWP MINIFY v 1.6 is not working with buddypress

    • User's Gravatar
      23
      OddOneOut August 31, 2011 at 12:58 pm – Permalink

      Hi akash,

      I have already been alerted about this, and a fix will be available shortly, so stay tuned!

  7. User's Gravatar
    24
    m September 1, 2011 at 10:57 pm – Permalink

    Hey there, I found a pretty rough bug that was a simple fix:: /includes/class-bwp-minify.php
    It complains about line 524 & 525, being a non-array, but the fix is in the header:: line 62:
    var $styles = array(array()), $media_styles = array(‘print’ => array()), $dynamic_styles = array(), $wp_styles_done = array();

    ..needed the extra “= array();” version 1.0.7, from the WP plugin installing system

    • User's Gravatar
      25
      OddOneOut September 2, 2011 at 12:19 am – Permalink

      Hi, thank you very much for the report. Even with WP_DEBUG set to true this bug did not show up in my test environment. This should only be a warning, so it won’t actually hurt I think, but 1.0.8 will be released shortly, stay tuned!

  8. User's Gravatar
    26
    Andy Neale September 4, 2011 at 7:58 pm – Permalink

    Hello again.

    I finally managed to get back to work on this theme after doing some work for a client and have now implemented bwm with my theme using the additional hooks and filters you provided in the last 2 releases and its all working perfectly 🙂

    There was just one thing I found. When the plugin is enabled, the wp login screen does not have any css, the bwm minified url seems to be incorrect.

    Initially I thought it may be something to do with the fact it is integrated from the theme, so disabled my integration and installed the plugin as usual, but as soon as I enabled it, I got the same result.

    I fixed it by adding bwp_minify_style_ignore() to ignore “‘login’, ‘colors-fresh'” and it works, but obviously there is something else going on so though I would post here.

    Here is a screenshot of what it looks like

    http://www.joomlajunkie.com/images/snaps/wpadmin-bmw-enabled.png

    I also reverted back to v1.0.5 and was the same, then with 1.0.4 everything worked, so my thinking is its a bug introduced in v 1.0.5.

    • User's Gravatar
      27
      OddOneOut September 5, 2011 at 11:42 pm – Permalink

      Hi Andy,

      May I use the email you’re using to post comments to contact you directly? I might need some help testing 1.0.8. To say the truth I wasn’t able to reproduce the issue, but since you’re the second user who encounters this, it’s time I need to take a careful look :). Thanks!

  9. User's Gravatar
    28
    Andy September 6, 2011 at 12:02 am – Permalink

    Sure thing, would be happy to test 🙂

    If it helps, here is the path that is created on the login screen

    http://wp.dev/zoo/wp-content/themes/bones/library/includes/bwp-minify/min/?f=wp-admin/css/login.css,wp-admin/css/colors-fresh.css

    And this is the error when I try open the page from source view

    400 Bad RequestPlease see http://code.google.com/p/minify/wiki/Debugging.

    I notice that the url is missing the “?f=zoo/” part, instead its just “?f=” so it is not adding the theme name on the login screen.

    • User's Gravatar
      29
      OddOneOut September 6, 2011 at 11:35 am – Permalink

      Ahh! I think I know the reason now, will send you 1.0.8 soon, stay tuned ;)!

      • User's Gravatar
        30
        Andy September 6, 2011 at 5:42 pm – Permalink

        Great! I thought that may be what you needed to figure it out 🙂

        By the way, I have another suggestions/request. It would be great to be able to override the “enable_auto” option of the plugin.. you know the first option “Minify CSS, JS files automatically?”

        This would allow me to have a theme option to enable/disable all performance with one switch.. like “developer mode” vs “live mode” for when a user is modding the theme. It’s impossible to work on modifying the theme when the everything is minified.

        I am actually already doing this by passing an empty array to the bwp_minify_allowed_scripts and bwp_minify_allowed_styles filters like this. This way they can enable or disable either css or js. However it does not allow for turning both off at once.

        add_filter('bwp_minify_allowed_scripts', 'slate_scripts');
        function slate_scripts()
        {
        	global $up_options;
        	$scripts_perf = $up_options->performance_scripts;
        	if (!$scripts_perf) :
        		return array();			
        	elseif ($scripts_perf == 'theme_only') :
        		return array('jquery','superfish','modenizer','nivo','jquery.isotope.min', 'jquery.infinitescroll.min', 'slate_js', 'logo_edit_js', 'jquery-ui-draggable');
        	elseif ($scripts_perf == 'all') :
        		return 'all';
        	endif;
        }
        

        What do you think?

        • User's Gravatar
          31
          OddOneOut September 10, 2011 at 3:58 pm – Permalink

          Hey Andy, I’ve sent you an email, make sure you check it and test the new version for me. Thanks :).

  10. User's Gravatar
    32
    Larry September 11, 2011 at 3:35 am – Permalink

    Thnanks for this plug, but I have a question. When I look at page source it shows it is calling fromt eh minify cache as it should but when I run YSlow, it still says the same thing, and still gives me a D rating on the speed.
    why would this be?
    thanks
    PS
    trying to spedd up my site to get a better ranking. with yslow and google.

    • User's Gravatar
      33
      OddOneOut September 11, 2011 at 9:02 pm – Permalink

      Hi Larry,

      The issue here is that your site’s using a lot of plugins that are echoing JS and CSS files directly, which renders BWP Minify useless. You should give WP Minify a try since it can minify anything on the page.

  11. User's Gravatar
    34
    Indolering September 20, 2011 at 3:39 am – Permalink

    Adding data uri encoding would speed up pages quite a big, more than GZip ever has.

    PHP has it built in via base64_encode().

    base64 does increase size and requires more processor time, so you may want to have a size limit and/or an option to scope images in CSS or template files only.

    From Wikipedia:

    <?php
    function data_uri($file, $mime) {
        $contents = file_get_contents($file);
        $base64 = base64_encode($contents);
        return "data:$mime;base64,$base64";
    }
    ?>
    

— Comments are closed.

Next Post: