Skip to content

Instantly share code, notes, and snippets.

@chriscoyier
chriscoyier / frontendplugins.md
Last active March 3, 2021 17:31
How WordPress Plugins Should Handle Front End Resources

How WordPress Plugins Should Handle Front End Resources

This is a WORK IN PROGRESS intended for fleshing out and feedback

It's very common for people to be unhappy with how a WordPress plugin adds front end resources to their site. If a plugin needs CSS, the plugin will add a <link> element to that CSS. If the plugin needs JavaScript, it will add a <script> to that JavaScript.

Plugins do this because it works. It's damn important for a WordPress plugin to work, even in adverse conditions. They rightfully want good ratings and little customer support.

But this comes at the cost of additional HTTP requests. In optimizing front end performance of a site, reducing the number of HTTP requests is a huge thing. Front end developers want to decide and control how front end resources are being handled, and WordPress plugins don't typically make this easy on them.

using UnityEngine;
using UnityEngine.EventSystems;
public static class ExtraMouseEvents
{
/// <summary>
/// Right mouse-click
/// </summary>
/// <param name="handler">Handler.</param>
/// <param name="data">Data.</param>
// Replacement module for Standalone Input Module
// Up to date for Unity 4.6 beta 19
//
// Usage:
// -Remove the standalone module from your event system
// -Add this instead
// -Include ExtraMouseEvents.cs and IExtraMouseEventsHandler.cs
// -Implement IRightPointerClickHandler, IRightPointerDownHandler, IRightPointerUpHandler, IMiddlePointerClickHandler,
// IMiddlePointerDownHandler and/or IMiddlePointerUpHandler.
//
@staltz
staltz / introrx.md
Last active May 15, 2025 10:37
The introduction to Reactive Programming you've been missing
@jixunmoe
jixunmoe / IntervalLoop.js
Last active November 26, 2018 13:38
Interval Loop (Loop array with delay & callback)
var IntervalLoop = function (arrData, looper, delay) {
if (!(this instanceof IntervalLoop))
return new IntervalLoop (arrData, looper, delay);
/**
* Status
* @type Number
* 0: 循环未开始
* 1: 正在循环
* 2: 循环结束
import com.sun.tools.attach.AgentInitializationException;
import com.sun.tools.attach.AgentLoadException;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.VirtualMachine;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
@timyates
timyates / wheee.groovy
Created January 27, 2014 12:51
Spinner whilst parsing files in Groovy on the command line
@Grab( 'com.bloidonia:groovy-common-extensions:0.5.5' )
@Grab('com.xlson.groovycsv:groovycsv:1.0')
import static com.xlson.groovycsv.CsvParser.parseCsv
import groovy.transform.*
// A bufferedReader with some output
@InheritConstructors
class SpinnerReader extends BufferedReader {
private String output = '/-\\|'
private int offset = 0
@victorquinn
victorquinn / promise_while_loop.js
Last active March 30, 2023 04:29
Promise "loop" using the Bluebird library
var Promise = require('bluebird');
var promiseWhile = function(condition, action) {
var resolver = Promise.defer();
var loop = function() {
if (!condition()) return resolver.resolve();
return Promise.cast(action())
.then(loop)
.catch(resolver.reject);
@also
also / gist:7729708
Last active June 1, 2021 09:02
how does /usr/libexec/java_home work?
# /usr/libexec/java_home -X
$ sudo opensnoop -n java_home
UID PID COMM FD PATH
501 79809 java_home 3 /System/Library/PrivateFrameworks/JavaLaunching.framework/Versions/A/JavaLaunching
501 79809 java_home 3 /dev/dtracehelper
501 79809 java_home 4 /System/Library/CoreServices/SystemVersion.bundle//English.lproj
501 79809 java_home -1 /System/Library/CoreServices/SystemVersion.bundle//Base.lproj
501 79809 java_home 4 /System/Library/CoreServices/SystemVersion.bundle/English.lproj/SystemVersion.strings
501 79809 java_home -1 /System/Library/CoreServices/SystemVersion.bundle/English.lproj/SystemVersion.stringsdict
501 79809 java_home 3 /usr/share/icu/icudt51l.dat