Switching Windows 10 Virtual Desktops using Swipe Gestures

I recently switched to Windows 10 to use the new Windows Subsystem for Linux. After switching, I’ve found Windows 10’s built in Virtual Desktops to be very useful. Previously, I’ve used VirtuaWin for virtual desktops on Windows, so having it built-in is very nice.

However, the other GUI OSes I use, OS X and Ubuntu, both support swipe gestures to switch between desktops or workspaces. Therefore, I wanted to add swipe gestures for switching between virtual desktops on Windows 10…

Drastically Speed Up WordPress with Progressive Loading

What is progressive loading?

“Progressive loading” can mean many different things. Generally, it means partially loading something first, then loading the rest later. In this article, “progressive loading” refers to loading HTML in chunks.

PHP uses buffers to improve efficiency. Buffers batch up PHP output so your server can send fewer responses. Without buffers, your server would have to send a response each time PHP generates output (e.g. by calling echo)…

Generators, Coroutines, Async/Await – The future of Javascript

This article assumes you’re already familiar with the basics of callback hell, promises, and the Javascript event loop.

For the past few years, promises are rapidly becoming popular. They make it much easier to deal with complicated asynchronous code than callbacks. However, we can do better than promises.

Problems with promises

Promises have several issues that can make large applications difficult to understand, debug, and maintain:

You can’t abort a chain of promises <pre></pre>

In this example, if we don’t want to run the rest of the promise chain, we use a throw to skip the processData

Best Javascript Frameworks: React, Redux, MobX, Vue

I often get asked “which Javascript framework should I use?” My answer is usually “it depends, but probably React.”

jQuery

jQuery is a Javascript library that helps you perform common tasks in Javascript. jQuery used to be extremely useful because it standardized behavior across browsers. Different browsers used to behave slightly differently; jQuery made those differences go away. Nowadays, the popular browsers all behave nearly identically, so jQuery isn’t as useful…

What is the Event Loop in Javascript

If you’ve written enough Javascript, you’ll encounter this for sure:

Why wait for 0 milliseconds? Why not just call doSomething directly?

The answer is that this setTimeout isn’t telling the Javascript engine to run doSomething after 0ms. Rather, it’s telling the Javascript engine to run doSomething after at least 0ms. This is a key distinction for understanding how Javascript works. doSomething could run almost immediately or it could run seconds later…

An Intro to RxJS and Observables: a General Version of Promises

Asynchronicity is arguably the hardest part of Javascript development. I’m assuming you’re already familiar with promises. If not, you can read about it and come back when you’re done. Understanding promises is crucial for modern web development.

Promises and RxJS

Promises solve Ajax callbacks very well. Remember the days when you had to handle multiple parallel Ajax requests with callbacks. How did you handle it if one fails? It probably wasn’t pretty…

Use the First Image in a Post as the Thumbnail in WordPress

To add a thumbnail to a post in WordPress, you need to manually add a “featured image” from the post editor. It’s possible to automatically use the first image in a post as the post’s thumbnail. Many themes do this automatically. There are also plugins that do this; one such plugin is Auto Post Thumbnail. However, if you don’t want to download a whole plugin, you can simply use the snippet below…

Enable a WordPress plugin for just one page

There are some plugins that are only used for specific pages on your blog. If you enable them globally, they will slow down the rest of your blog. WordPress doesn’t come with a built-in feature to conditionally enable plugins. I can’t even find a WordPress plugin that does this.

If you want to enable a WordPress plugin for just a single page, add this snippet to your functions.php:

For example, I’m using The SEO Framework as my SEO plugin…

Using APCu with PHP 7, WordPress, and W3 Total Cache

APC consists of 2 parts: opcode caching and memory caching. PHP 5.5 and newer have built-in opcode caching, so APC is no longer supported. A new PECL package, APCu, was created for the memory caching part. The prefix for APC memory caching functions changed from “apc” to “apcu”. For example, apc_store became apcu_store and apc_fetch became apcu_fetch.

APCu Backwards Compatibility

Some plugins, such as W3 Total Cache, are still using the apc_* functions…

W3 Total Cache Optimization: Caching Post Taxonomies

Today I installed Query Monitor and noticed that each post on my homepage was triggering 2 database queries. One query retrieved the post_tag post taxonomy and one retrieved the post_format post taxonomy. Since my homepage has up to 15 posts, there can be 30 extra queries. These values should have been fetched all at once; they should not be fetched from the database individually.

Database queries logged by Query Monitor

I disabled my plugins one-by-one and realized that the issue was caused by W3 Total Cache

Best Way to Add a Favicon and App Icons to WordPress

Favicons are the icons displayed on browser tabs. They help form the identity and brand of a WordPress blog.

App icons are a way to help bridge web apps and mobile apps. On popular mobile browsers such as Chrome and Safari, you can add shortcuts to webpages on your homescreen. These shortcuts look like apps, but they’re essentially bookmarks. Mobile browsers use your blog’s app icons as the icons for these shortcuts…

Make all links have relative URLs in WordPress posts

WordPress’s TinyMCE editor makes all links use absolute URLs with your blog’s siteurl as the base. Your blog’s siteurl is the value in Settings > General Settings > WordPress Address (URL). This value is hardcoded in your posts. This means that if you change your domain, change your permalink structure, or switch from http to https, you’ll have to update your posts. Also, you cannot support both http and https; you have to choose one…

Load jQuery from Google’s CDN in WordPress

WordPress loads jQuery from your server by default. It’s much better to load jQuery from Google’s CDN (content delivery network). Here are the 4 main reasons:

  1. Your visitors probably already have jQuery from Google’s CDN cached. This means jQuery will load nearly instantly.
  2. It’s probably faster to load jQuery from Google’s servers than your servers. They have faster servers and better networks. They also probably have a data center that’s closer to your visitor.