Created
June 22, 2014 01:43
-
-
Save donaldallen/d0be4c6ff16e08b86ebf to your computer and use it in GitHub Desktop.
Adds async="true" to your enqueued picturefil(.min).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Picturefill Async | |
* Description: Adds <code>async</code> to picturefill's enqueued js. | |
* Version: 1.0 | |
* Required: 3.9 | |
* Author: Donald Allen | |
* Author URI: http://donaldallen.com/ | |
* License: GPL | |
* License URI: http://www.gnu.org/copyleft/gpl.html | |
*/ | |
if (!defined('ABSPATH')) { | |
exit; | |
} | |
if (!function_exists('picturefill_async')) { | |
function picturefill_async($url) | |
{ | |
if (!strpos($url, 'picturefill')) { | |
return $url; | |
} | |
return "$url' async='true"; | |
} | |
add_filter('clean_url', 'picturefill_async', 11, 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also, sample of using a device-pixel-ratio media query: