Social share scripts are convenient and easy to copy & paste but rely on JavaScript and add additional overhead to your site, which means more HTTP requests and slower load times. Instead, use share links that don’t require you to load scripts for each social site.
Convert and Loop through JSON with PHP and JavaScript Arrays/Objects
If you’re working with JSON (JavaScript Object Notation) and either need to convert a JSON string to array or object and loop through it or vice-versa, take an array or object and convert it to a JSON string to return, both can be done in PHP or JavaScript.
Detect the End of CSS Animations and Transitions with JavaScript
CSS allows you to create animations with transitions and keyframes that once were only possible with JavaScript or Flash. Unfortunately, with CSS there’s no way to perform a callback when an animation is complete. With JavaScript, it’s possible to detect the end of a CSS transition or animation and then trigger a function.
Animate SVG with CSS
Animating SVG with CSS is like animating any other element with CSS—it can be done with transitions, transforms, and keyframe animations. Once you’re familiar with the markup of an SVG, the rest is fairly straight forward.
Retina Image Replacement
To ensure your images are sharp and crisp on retina-enabled devices, you want to serve images that are twice as large and scale them down appropriately; however, keeping mobile users and their limited speeds and data plans in mind, it’s important to only serve retina images on retina-enabled devices or when necessary.
Here’s a quick-and-easy way to do it with just a few lines of vanilla JavaScript or jQuery.
Configure WordPress for Multiple Environments
By default, WordPress is set up to run in one environment—it has one configuration file, wp-config.php
, that holds one set of database credentials along with authentication keys/salts and debugging options. With just a few tweaks, you can get WordPress set up to handle multiple environments with different databases and options for each environment.
Take Grunt to the Next Level
Now that you’ve started to integrate Grunt into your development workflow, here are a few tips to tidy up and optimize your Grunt setup along with plugins that you may find useful for development.
Sass BEM-Selector Support and Trailing Ampersand
Sass 3.3 has introduced some neat features with the ampersand—it now has BEM-selector support and allows you to prepend a class to the parent element.
Organizing z-index with Sass
Keeping track of all your z-index values can be quite a task, especially on large projects or projects that involve more than 1 developer. Sass and its recent introduction of the maps
data-type can help you keep track of your z-index by having them all in one place.
Sass Maps
Sass 3.3 introduced a new maps
data type—you can create a variable that holds comma-separated, key-value pairs, and allows you to do some neat things like call a value by the key or loop through the key-value pairs.