Skip to content

Instantly share code, notes, and snippets.

@bejes
bejes / spancount.js
Created October 19, 2012 02:29
Simple jquery plugin to insert spans in text and a defined character limit
/**
* Plugin function to insert spans into text:
* usage
* $(document).ready(function() {
* $('p.charcount').charSpanCount(); });
* or $(document).ready(function() {
* $('p.charcount').charSpanCount({'charcount' : 15});
* });
*/
(function($) {
@johnpolacek
johnpolacek / responsive-viewport
Created November 16, 2012 18:57
Responsive Viewport
<script language="javascript">
// set viewport to zoom to 1200px wide on viewports > 640px wide
var viewPortTag = document.createElement('meta');
viewPortTag.id = 'viewport';
viewPortTag.name = 'viewport';
if (screen.width > 640) {
viewPortTag.content = 'width=1200';
} else {
viewPortTag.content = 'width=device-width';
}
@ratherironic
ratherironic / idonteven.css
Last active December 27, 2015 12:48
This is kinda amazing that this Works : JS in CSS
#emptyDiv:after {
content: 'alert("you gotta be kidding me")';
}
@paulirish
paulirish / what-forces-layout.md
Last active May 20, 2024 06: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