Skip to content

Instantly share code, notes, and snippets.

View matt-bailey's full-sized avatar

Matt Bailey matt-bailey

  • GPMD
  • London, UK
View GitHub Profile
@matt-bailey
matt-bailey / async-and-conditional-css-loading.html
Last active March 17, 2021 22:09
A simple script (based on one by Google) for loading CSS files asynchronously and conditionally based on body tag classes
<html>
<head>
<!-- Inlined critical styles -->
<style>.blue{color:blue;}</style>
<!-- CSS loader -->
<script>
/* ==========================================================================
Load CSS asynchronously and conditionally after initial painting
(function($) {
$.fn.helloWorld = function() {
this.each( function() {
$(this).text("Hello, World!");
});
}
}(jQuery));
@matt-bailey
matt-bailey / .gitignore
Last active January 2, 2016 14:59
Supporting files for a Beginner’s Guide to using Grunt with Magento: http://www.gpmd.co.uk/blog/a-beginner-s-guide-to-using-grunt-with-magento/
.idea/
.project
*.sublime-project
*.sublime-workspace
*.tmproj
*.bak
*.swp
*~.nib
.sass-cache/
node_modules/
@matt-bailey
matt-bailey / Test.js
Last active January 2, 2016 14:49
Test stuff...
console.log("Some inline code");
{
"name": "my-theme",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-compass": "~0.7.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-imagemin": "~0.4.0",
$ npm install grunt
npm http GET https://registry.npmjs.org/grunt
npm http 304 https://registry.npmjs.org/grunt
npm http GET https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/coffee-script
npm http GET https://registry.npmjs.org/colors
npm http GET https://registry.npmjs.org/dateformat/1.0.2-1.2.3
npm http GET https://registry.npmjs.org/eventemitter2
npm http GET https://registry.npmjs.org/findup-sync
npm http GET https://registry.npmjs.org/glob
@matt-bailey
matt-bailey / Gruntfile.js
Last active November 13, 2017 18:56
This is the example Gruntfile that goes with my tutorial on front-end flat builds and automation: http://www.gpmd.co.uk/blog/front-end-process-flat-builds-and-automation-part-3-grunt-tasks/
// Generated on 2013-06-04 using generator-webapp 0.1.7
'use strict';
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
@matt-bailey
matt-bailey / gist:5815536
Created June 19, 2013 16:05
The 'watch' task in Gruntfile.js (as scaffolded by yo webapp)
grunt.initConfig({
yeoman: yeomanConfig,
watch: {
coffee: {
files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
tasks: ['coffee:dist']
},
coffeeTest: {
files: ['test/spec/{,*/}*.coffee'],
tasks: ['coffee:test']
@matt-bailey
matt-bailey / gist:5765048
Created June 12, 2013 13:04
Yeoman - Yo webapp generator directory structure
myproject/
|-- .sass-cache/
|-- .tmp/
|-- app/
| |-- components/
| |-- images/
| |-- scripts/
| `-- styles/
|-- dist/
| |-- components/
@matt-bailey
matt-bailey / gist:5765024
Created June 12, 2013 13:00
How to install Yeoman
npm install -g yo grunt-cli bower
@matt-bailey
matt-bailey / grunt --force output
Created April 26, 2013 13:36
Output when running 'grunt --force'
>> Local Npm module "grunt-mocha" not found. Is it installed?
Running "jshint:all" (jshint) task
>> 4 files lint free.
Warning: Task "mocha" not found. Used --force, continuing.
Running "clean:dist" (clean) task
Running "useminPrepare:html" (useminPrepare) task
Going through app/index.html to update the config