diff --git a/bwp-minify.php b/bwp-minify.php
index 695d1ed..8133a96 100644
--- a/bwp-minify.php
+++ b/bwp-minify.php
@@ -3,7 +3,7 @@
Plugin Name: Better WordPress Minify
Plugin URI: http://betterwp.net/wordpress-plugins/bwp-minify/
Description: Allows you to minify your CSS and JS files for faster page loading for visitors. This plugin uses the PHP library Minify and relies on WordPress's enqueueing system rather than the output buffer (will not break your website in most cases). This plugin is very customizable and easy to use.
-Version: 1.2.3
+Version: 1.2.3-1
Text Domain: bwp-minify
Domain Path: /languages/
Author: Khang Minh
@@ -15,9 +15,12 @@
if (class_exists('BWP_MINIFY'))
return;
-// Frontend
-require_once('includes/class-bwp-minify.php');
-$bwp_minify = new BWP_MINIFY();
+// DBS HB 2013-11-02
+if ( ! defined( 'BWP_DISABLED' ) || BWP_DISABLED === 'false' || BWP_DISABLED === false || is_admin() ) {
+ // Frontend
+ require_once('includes/class-bwp-minify.php');
+ $bwp_minify = new BWP_MINIFY();
+}
// Backend
add_action('admin_menu', 'bwp_minify_init_admin', 1);
@@ -26,4 +29,4 @@ function bwp_minify_init_admin()
{
global $bwp_minify;
$bwp_minify->init_admin();
-}
\ No newline at end of file
+}
diff --git a/includes/class-bwp-minify.php b/includes/class-bwp-minify.php
index e997ecb..fc0311d 100644
--- a/includes/class-bwp-minify.php
+++ b/includes/class-bwp-minify.php
@@ -73,7 +73,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK {
/**
* Constructor
*/
- function __construct($version = '1.2.3')
+ function __construct($version = '1.2.3-1')
{
// Plugin's title
$this->plugin_title = 'BetterWP Minify';
@@ -98,6 +98,7 @@ function __construct($version = '1.2.3')
'enable_min_js' => 'yes',
'enable_min_css' => 'yes',
'enable_bloginfo' => 'yes',
+ 'defer_js' => 'no',
'select_buster_type' => 'none',
'select_time_type' => 60
);
@@ -240,13 +241,14 @@ function build_option_pages()
if ($page == BWP_MINIFY_OPTION_GENERAL)
{
$form = array(
- 'items' => array('heading', 'checkbox', 'checkbox', 'checkbox', 'heading', 'input', 'input', 'input', 'select', 'heading', 'textarea', 'textarea', 'textarea', 'textarea'),
+ 'items' => array('heading', 'checkbox', 'checkbox', 'checkbox', 'checkbox', 'heading', 'input', 'input', 'input', 'select', 'heading', 'textarea', 'textarea', 'textarea', 'textarea'),
'item_labels' => array
(
__('General Options', 'bwp-minify'),
__('Minify JS files automatically?', 'bwp-minify'),
__('Minify CSS files automatically?', 'bwp-minify'),
__('Minify bloginfo() stylesheets?', 'bwp-minify'),
+ __('Defer JavaScript', 'bwp-minify'),
__('Minifying Options', 'bwp-minify'),
__('Minify URL (double-click to edit)', 'bwp-minify'),
__('Cache directory (double-click to edit)', 'bwp-minify'),
@@ -258,7 +260,7 @@ function build_option_pages()
__('Scripts to be minified and then printed separately', 'bwp-minify'),
__('Scripts to be ignored (not minified)', 'bwp-minify')
),
- 'item_names' => array('h1', 'cb1', 'cb3', 'cb2', 'h2', 'input_minurl', 'input_cache_dir', 'input_maxfiles', 'select_buster_type', 'h3', 'input_header', 'input_footer', 'input_direct', 'input_ignore'),
+ 'item_names' => array('h1', 'cb1', 'cb3', 'cb2', 'cb4', 'h2', 'input_minurl', 'input_cache_dir', 'input_maxfiles', 'select_buster_type', 'h3', 'input_header', 'input_footer', 'input_direct', 'input_ignore'),
'heading' => array(
'h1' => '',
'h2' => __('Options that affect both your stylesheets and scripts.', 'bwp-minify'),
@@ -282,7 +284,8 @@ function build_option_pages()
'checkbox' => array(
'cb1' => array(__('you can still use bwp_minify() helper function if you disable this.', 'bwp-minify') => 'enable_min_js'),
'cb3' => array(__('you can still use bwp_minify() helper function if you disable this.', 'bwp-minify') => 'enable_min_css'),
- 'cb2' => array(__('most themes (e.g. Twenty Ten) use bloginfo() to print the main stylesheet (i.e. style.css) and BWP Minify will not be able to add it to the main minify string. If you want to minify style.css with the rest of your css files, you must enqueue it.', 'bwp-minify') => 'enable_bloginfo')
+ 'cb2' => array(__('most themes (e.g. Twenty Ten) use bloginfo() to print the main stylesheet (i.e. style.css) and BWP Minify will not be able to add it to the main minify string. If you want to minify style.css with the rest of your css files, you must enqueue it.', 'bwp-minify') => 'enable_bloginfo'),
+ 'cb4' => array(__('Deferring JavaScript can improve browser rendering speed.', 'bwp-minify') => 'defer_js')
),
'input' => array(
'input_minurl' => array('size' => 55, 'disabled' => ' readonly="readonly"', 'label' => sprintf(__('This should be set automatically. If you think the URL is too long, please read here to know how to properly modify this.', 'bwp-minify'), $this->plugin_url)),
@@ -311,8 +314,8 @@ function build_option_pages()
);
// Get the default options
- $options = $bwp_option_page->get_options(array('input_minurl', 'input_cache_dir', 'input_maxfiles', 'input_header', 'input_footer', 'input_direct', 'input_ignore', 'input_custom_buster', 'select_buster_type', 'enable_min_js', 'enable_min_css', 'enable_bloginfo'), $this->options);
-
+ $options = $bwp_option_page->get_options(array('input_minurl', 'input_cache_dir', 'input_maxfiles', 'input_header', 'input_footer', 'input_direct', 'input_ignore', 'input_custom_buster', 'select_buster_type', 'enable_min_js', 'enable_min_css', 'enable_bloginfo', 'defer_js'), $this->options);
+
// Get option from the database
$options = $bwp_option_page->get_db_options($page, $options);
@@ -557,6 +560,11 @@ function is_local($src = '')
if (false === strpos($src, '://') && substr($src, 0, 1) != '/') {
$src = 'http://'. $src;
}
+ // DBS 2013-11-25, handle protocol-less scheme
+ if (strncmp($src, '//', 2) == 0) {
+ $protocol = stripos($_SERVER['SERVER_PROTOCOL'],'https') === true ? 'https:' : 'http:';
+ $src = $protocol . $src;
+ }
$url = @parse_url($src);
$blog_url = @parse_url(home_url());
if (false === $url)
@@ -749,7 +757,9 @@ function get_minify_tag($string, $type, $media = '')
switch ($type)
{
case 'script':
- $return = "\n";
+ // DBS 2013-11-03
+ $defer = ( 'yes' === $this->options[ 'defer_js' ] ) ? $defer = 'defer="defer" ' : '';
+ $return = "\n";
break;
case 'style':
@@ -1190,4 +1200,4 @@ function print_footer_scripts_l10n()
$this->print_scripts_l10n($this->footer_l10n);
}
}
-?>
\ No newline at end of file
+?>
diff --git a/min/config.php b/min/config.php
index 33829a1..a728588 100644
--- a/min/config.php
+++ b/min/config.php
@@ -91,7 +91,8 @@
* move all @imports to the top of the output. Note that moving @imports could
* affect CSS values (which is why this option is disabled by default).
*/
-$min_serveOptions['bubbleCssImports'] = false;
+ // DBS 2013-11-26, set to true ... why not?
+$min_serveOptions['bubbleCssImports'] = true;
/**
@@ -103,7 +104,8 @@
* Note: Despite this setting, if you include a number at the end of the
* querystring, maxAge will be set to one year. E.g. /min/f=hello.css&123456
*/
-$min_serveOptions['maxAge'] = 7200;
+// DBS 2013-12-15, increase max age for better caching
+$min_serveOptions['maxAge'] = 86400*10;
/**
diff --git a/min/lib/Minify/Cache/File.php b/min/lib/Minify/Cache/File.php
index 27b424a..bed32cb 100644
--- a/min/lib/Minify/Cache/File.php
+++ b/min/lib/Minify/Cache/File.php
@@ -97,7 +97,11 @@ public function display($id)
public function fetch($id)
{
if ($this->_locking) {
- $fp = fopen($this->_path . '/' . $id, 'rb');
+ // FIXME: this occasionally spits out bogus "no such file" warnings and cannot modify header noise. Possibly due to symlinks. 2013-11-13 HB
+ @$fp = fopen($this->_path . '/' . $id, 'rb');
+ if ( false === $fp ) {
+ return;
+ }
flock($fp, LOCK_SH);
$ret = stream_get_contents($fp);
flock($fp, LOCK_UN);
diff --git a/readme.txt b/readme.txt
index e0ff92d..218ae7a 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,15 +1,17 @@
=== Better WordPress Minify ===
-Contributors: OddOneOut
+Contributors: OddOneOut, dbswebsite
Donate link: http://betterwp.net/wordpress-plugins/bwp-minify/
Tags: CSS, javascript, JS, minify, minification, optimization, optimize
Requires at least: 2.8
Tested up to: 3.7
-Stable tag: 1.2.3
+Stable tag: 1.2.3-1
Allows you to minify your CSS and JS files for faster page loading for visitors.
== Description ==
+This fork adds the ability to defer JavaScript.
+
**BWP MINIFY IS WORDPRESS 3.7 COMPATIBLE**
Allows you to minify your CSS and JS files for faster page loading for visitors. This plugin uses the PHP library [Minify](http://code.google.com/p/minify/) and relies on WordPress's enqueueing system rather than the output buffer (will not break your website in most cases). This plugin is very customizable and easy to use.
@@ -74,6 +76,10 @@ Please [help translate](http://betterwp.net/wordpress-tips/create-pot-file-using
== Changelog ==
+= 1.2.3-1 =
+* Add a configuration option for deferring JavaScript
+* Create a constant that allows programatically disabling BWP, ie BWP_DISABLED.
+
= 1.2.3 =
* BWP Minify is now WordPress 3.7 compatible (compatibility issues with WordPress 3.5 and 3.6 have been fixed).
* Updated Minify library to version 2.1.7 (security fix). This updated version of Minify also comes with an updated version of CSSMin library, which solves relative path issues in some plugins' CSS files (such as TablePress).
@@ -183,4 +189,4 @@ Please [help translate](http://betterwp.net/wordpress-tips/create-pot-file-using
== Upgrade Notice ==
= 1.0.0 =
-* Enjoy the plugin!
\ No newline at end of file
+* Enjoy the plugin!