Skip to content

Instantly share code, notes, and snippets.

View timmywil's full-sized avatar
🚀
Working on @spokestack

Timmy Willison timmywil

🚀
Working on @spokestack
View GitHub Profile
@timmywil
timmywil / what-forces-layout.md
Created June 17, 2016 17:22 — forked from paulirish/what-forces-layout.md
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.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
var foo = function foo() {
foo = 5;
console.log(foo);
};
foo();
// outputs: [Function foo]
<body>
<div id="foo">...</div>
<script src="jquery.js"></script>
<script>
$( "#foo" ).offset();
</script>
</body>
@timmywil
timmywil / jquery.hasattr.js
Created July 10, 2011 17:55 — forked from rwaldron/jquery.hasattr.js
A commonly requested feature that is simply not worth adding to jQuery core. Usage: http://jsfiddle.net/rwaldron/kSmP2/
/*!
* jQuery.fn.hasAttr()
*
* Copyright 2011, Rick Waldron
* Licensed under MIT license.
*
*/
(function( jQuery ) {
jQuery.fn.hasAttr = function( name ) {
for ( var i = 0, l = this.length; i < l; i++ ) {
// get xml file & publish
km.core = {
url: 'someDir/someFile',
fetch: $.get(url, function(xml) {
$.publish('xmlFetch', [xml]);
})
};
// subscribe to xml file and do stuff
km.widget.edVolGraph = {