Self-invoking functions in PHP

For a small PHP framework that I am refactoring, I needed to isolated variables from the framework in the output. Before, these variables could be called in the PHP templates, if you knew them (or guess them). Also $this was available because the templates are called inside a class. This can potentially introduce security issues,…

Gracefully ignoring old browsers

New front-end techniques popping up all the time. Because these changes are moving very fast, supporting old browser might seem tedious. But there are some techniques to make this easier. To achieve this, you need to accept that webpages do not need to look the same in every browser. For example, responsive designs have a…

A HTML5 aria-expanded toggle button

A lot is possible with web standards without using frameworks or libraries. Support in browsers has become very good, compared to a couple of years ago. With the introduction of the document.querySelector, CSS selectors can be used with JavaScript in almost all browsers, including IE8. In the past you would have needed a library like…

Only load JS/CSS for Contact Form 7 when needed

Contact Form 7 is a popular plugin for WordPress to add forms to a site. The plugin is free, and a lot of add-ons are also available. To add a form to a page you will have to use a shortcode. A problem with shortcodes is, that one does not know when a shortcode is…

Creating a smoother CSS zoom effect

A zoom effect can be created with the transform and transition CSS properties. I have been using this on a project and was not entirely happy with the result. For the project I created a grid with articles that become larger if you move the mouse over the article. The article contains an image and…