Skip to content

Instantly share code, notes, and snippets.

@paulirish
paulirish / what-forces-layout.md
Last active April 26, 2024 17:33
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

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.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@JamieMason
JamieMason / protractor_members.txt
Created July 4, 2013 09:52
Methods available to you in a Jasmine test using https://github.com/juliemr/protractor/
protractor.wrapDriver
protractor.setInstance
protractor.getInstance
protractor.By
protractor.By.binding
protractor.By.select
protractor.By.selectedOption
protractor.By.input
protractor.By.repeater
@r10r
r10r / enable_dnsmasq_on_osx.sh
Last active October 11, 2019 04:27
Installs and configures dnsmasq on osx (for local resolution of development machines e.g virtualbox). Cudos to Alan Ivey http://www.echoditto.com/blog/never-touch-your-local-etchosts-file-os-x-again
# ----------------------
# installing dnsmasq and enable daemon
# ----------------------
brew install dnsmasq
sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
# ----------------------
# adding resolver for vbox domain
# ----------------------
[ -d /etc/resolver ] || sudo mkdir -v /etc/resolver
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/vbox'
@wanderingmatt
wanderingmatt / _retina-sprite.scss
Created October 1, 2012 17:19
Mixin that generates both a regular and retina sprite (using the Compass Sprite Helpers) and returns the appropriate declarations and media queries.
// Mixin that generates both a regular and retina sprite (using the Compass Sprite Helpers) and returns the appropriate declarations and media queries.
//
// $folder - The name of the folder that contains the icons to sprite.
//
// No styleguide reference.
@mixin retina-sprite($folder) {
$sprites: sprite-map("icons/#{$folder}/*.png"); // Generates a sprite containing every icon in the supplied folder.
$sprites-2x: sprite-map("icons/#{$folder}@2x/*.png"); // Generates a second sprite containing every icon @2x resolution.
@orderedlist
orderedlist / labels.scss
Created July 9, 2012 18:42
Simple Label Colors with SCSS
$start-color:#2B73A2;
$number: 12;
@for $i from 1 through $number {
.label-#{$i} {
color:adjust_hue($start-color, ($i - 1) * (360 / $number));
}
}
@sdhull
sdhull / pre-commit
Created April 17, 2012 23:36
.git/hooks/pre-commit
#!/usr/bin/env ruby
file_names = `git diff-index --cached -Sdebugger --name-only HEAD`
file_names += `git diff-index --cached -Ssave_and_open_page --name-only HEAD`
file_names = file_names.strip
if file_names != ""
puts "The following files have 'debugger' or 'save_and_open_page' statements in them: "
puts file_names
raise "Please complete your merge prior to committing" unless ENV["FORCE"]
end
@steveclarke
steveclarke / capybara.md
Created April 10, 2012 17:32
RSpec Matchers

Capybara

save_and_open_page

Matchers

have_button(locator)
@thulstrup
thulstrup / compass-retina-sprites.scss
Created March 20, 2012 19:18
Using Compass to generate normal and retina sprite maps
$sprites: sprite-map("sprites/*.png");
$sprites-retina: sprite-map("sprites-retina/*.png");
@mixin sprite-background($name) {
background-image: sprite-url($sprites);
background-position: sprite-position($sprites, $name);
background-repeat: no-repeat;
display: block;
height: image-height(sprite-file($sprites, $name));
width: image-width(sprite-file($sprites, $name));
@rgrove
rgrove / gist:2046918
Created March 15, 2012 21:02
How `this` works in browser JS
console.log(this); // => window (the global object)
var myObject = {};
function foo() {
console.log(this);
}
foo(); // => window
foo.call(myObject); // => myObject
@sr75
sr75 / run-ie-7-8-9-virtualbox-on-osx.txt
Created March 15, 2012 13:52
Run IE 7, 8, and 9 in Mac OS X
# the admin password for all of the IE VMs is “Password1″ without the quotes, it's also used for the password hints
1) Install VirtuaBox on your mac
http://download.virtualbox.org/virtualbox/4.1.10/VirtualBox-4.1.10-76795-OSX.dmg
2) Decide which versions of Internet Explorer you want to download and install – each version of Internet Explorer is contained within a separate virtual machine that runs within VirtualBox. In other words, if you want to run Internet Explorer 7, 8, and 9, you will need to download three separate VM’s, which may take a while so keep that in mind. Select the text below and copy it:
# Install ALL versions of Internet Explorer: IE 7, IE 8, and IE 9 (for now this script will also pull down a IE 6 vm with windows xp)