Category Archives: Internet

All blogposts on about Internet (browsers, web development and mobile web).

Autoptimize to allow optimizing whitelisted resources only (and more)

Although work is still ongoing on what will become Autoptimize 2.0, I thought I’d share an (API-only) feature that allows developers/ web agencies to only aggregate & minify a fixed set of known-good resources only. This whitelist-based optimization will allow for a more stable situation upon delivery of your project to customers, as the CSS/ JS of plugins that are installed by your customer will not be autoptimized, so the site is less likely to break by accident.

The following example-code shows how to tell Autoptimize to only aggregate & minify jquery.js and jquery-migrate.min.js;

function example_js_whitelist() {
return "jquery.js,jquery-migrate.min.js";

Using autoptimize_filter_css_whitelist allows you to accomplish the exact same things for CSS. The guys over at are already using autoptimize_filter_js_whitelist, so we must at least be doing something right there.

Some other new filters that might prove helpful;

  • autoptimize_filter_css_removables and autoptimize_filter_js_removables will allow you to specify which CSS or JS should actually be removed alltogether (Google Fonts, Emoji’s, … all in case you don’t like dequeuing off course)
  • autoptimize_filter_css_inlinesize allows you to specify up until how many characters of optimized CSS should be inlined instead of linked (can be useful for print CSS). Default value is 128, but I might bump that to 256 actually.
  • passing “true” to autoptimize_filter_css_fonts_cdn will tell AO to try to switch the font URL’s to your CDN
  • autoptimize_filter_cssjs_multidomain takes an array which can be used to tell AO that are also to be considered local domains and resources from those can be optimize (warning; as AO aggregates from the filesystem, this only works if the resources are actually local)
  • autoptimize_filter_cachecheck_do, autoptimize_filter_cachecheck_frequency and autoptimize_filter_cachecheck_maxsize can be used to control the wp-cronned cachechecker that will get triggered daily

Non-API improvements include performance optimizations, out-of-the box support for WPML subdomain-based language-variations and a whole heap of smaller improvements and bugfixes (e.g. the fact that if you have multiple title-tags, the optimized CSS would be injected in front of every one of those).

So yeah, I’d say we almost have ourselves a release. Only major thing still to go in; swapping the “look only in head” for an “include inline code” option. And testing of course, but that’s one area where I am looking at YOU, dear reader! Download the in-development version from GitHub and test away!

WP YouTube Lyte: new player UI and API tips

WP YouTube Lyte 1.6.4 was released a couple of hours ago and features the new YouTube player look and feel:

Vieux Farka Touré & Julia Easterlin – Little Things (Music Video)

Watch this video on YouTube.

Here are some tips on how you can tweak that to match your own preferences;

As you can see in the vid above (Vieux Farka Touré & Julia Easterlin – Little Things), I wanted WP YouTube Lyte to show the bottom control (which as on YouTube is now invisible by default) add can be accomplished with just a little CSS:

.ctrl{display:block !important;}</code>

If you’d like Lyte to use the exact same font as YouTube does, you can add CSS to import that font and it will be applied to title-field in Lyte:

@import url(,latin-ext);

You can even use Lyte’s API do alter the CSS like this;

function lyte_change_css($lyte_css) {
        // source the font
        $lyte_css="@import url(,latin-ext);".$lyte_css;
        // show bottom control
        $lyte_css.=" .ctrl{display:block !important;}";
        return $lyte_css;

Talking about the API, you can now also force Lyte to be active on mobile as well (which is not the default as it would force your visitors to click “play” twice, once to load the YouTube iFrame and once to play as mobile YouTube doesn’t support autoplay), you can use this code;

function lyte_on_mobile(){
        return true;

Solve WP Super Cache + Autoptimize Internal Server Errors

Yesterday I noticed my autoptimized JS-files were returning an internal server error (CSS worked as that is inlined). My Apache error-log had this entry:

[Tue Oct 13 17:23:42 2015] [alert] [client 178.xx.xx.xx] /var/public_html/ Option Indexes not allowed here

/var/public_html/ is created by WP Super Cache, which got updated recently, a.o. to disable indexes being created of directories, and the .htaccess indeed read;

Options -Indexes

The solution? I could have edited WPSC’s .htaccess, but my changes could get overwritten there whenever Donncha would feel like it, so in the end I edited my site’s config in Apache;

<directory /var/public_html/>
AllowOverride All

And all is well now.

3 interesting WordPress plugins

I came across some interesting WordPress plugins and thought I’d document these quickly;

  1. Warm Cache; have your site crawled based on your sitemap.xml to re-generate your cache (applicable to both your page cache and Autoptimize’s cache)
  2. Duplicator: export your entire WordPress installation to an archive and install elsewhere. Haven’t tried this yet, but might come in very handy at some point.
  3. Code Snippets: don’t burden your theme’s functions.php with your own code (risking losing the changes with a theme update), but use Code Snippets instead. Handy if you want to e.g. tell Autoptimize not to be active on specific pages or if you want WP YouTube Lyte to also act on youtube-links in text widgets for example.