// jQuery
$(document).ready(function() {
// code
})
<?php | |
/** | |
* mix | |
* | |
* @param mixed $color_1 | |
* @param mixed $color_2 | |
* @param mixed $weight | |
* | |
* @return void |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft
,elem.offsetTop
,elem.offsetWidth
,elem.offsetHeight
,elem.offsetParent
function syntaxHighlight(json) { | |
json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); | |
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) { | |
var cls = 'number'; | |
if (/^"/.test(match)) { | |
if (/:$/.test(match)) { | |
cls = 'key'; | |
} else { | |
cls = 'string'; | |
} |
<?php | |
/** | |
* Searches the database for transients stored there that match a specific prefix. | |
* | |
* @author Brad Parbs, Kellen Mace | |
* @param string $prefix prefix to search for. | |
* @return array nested array response for wpdb->get_results. | |
*/ | |
function wds_campbell_search_database_for_transients_by_prefix( $prefix ) { |
Recently when refactoring a Vue 1.0 application, I utilized ES6 arrow functions to clean up the code and make things a bit more consistent before updating to Vue 2.0. Along the way I made a few mistakes and wanted to share the lessons I learned as well as offer a few conventions that I will be using in my Vue applications moving forward.
The best way to explain this is with an example so lets start there. I'm going to throw a rather large block of code at you here, but stick with me and we will move through it a piece at a time.
<script>
// require vue-resource...
new Vue({
:root { | |
/* Standard Curves */ | |
--LINEAR : cubic-bezier(0.250, 0.250, 0.750, 0.750); | |
--EASE : cubic-bezier(0.250, 0.100, 0.250, 1.000); | |
--EASE_IN : cubic-bezier(0.420, 0.000, 1.000, 1.000); | |
--EASE_OUT : cubic-bezier(0.000, 0.000, 0.580, 1.000); | |
--EASE_IN_OUT : cubic-bezier(0.420, 0.000, 0.580, 1.000); | |
/* Ease IN curves */ |
const puppeteer = require('puppeteer'); | |
const imagemin = require('imagemin'); | |
const imageminPngquant = require('imagemin-pngquant'); | |
// Get the URL and the slug segment from it | |
const url = process.argv[2]; | |
const segments = url.split('/'); | |
const slug = segments[segments.length-2]; | |
(async () => { |
To set up php linting, you’ll want to install this PHP CodeSniffer repo and configure with this WordPress Coding Standards repo: . There are a number of ways to do this, whether direct download, Composer, Homebrew, Pear, etc. The following is what works for me on MacOS using Homebrew:
In a terminal window on your Mac, start by updating your Homebrew.
brew doctor
Then install the Code Sniffer: