Created
May 4, 2012 16:58
-
-
Save liamcurry/2596218 to your computer and use it in GitHub Desktop.
HTMl/CSS/JS quickies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* String to Number */ | |
var hello = '1234' | |
parseInt(hello) // Use this when speed is a concern (see http://jsperf.com/parseint-vs-unary) | |
// 1234 | |
+hello // unary operator -- use this when file size is a concern | |
// 1234 | |
+hello++ // Converts `hello` to a number and adds 1 to it | |
// 1 | |
/* Number to String */ | |
var hello = 1234; | |
hello.toString() // Try not to use this... | |
// "1234" | |
hello + '' // Use this instead (http://jsperf.com/tostring-vs-concat-coercion) | |
// "1234" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[hidden] { | |
display: none; | |
} | |
iframe[seamless] { | |
border: 0 none transparent; | |
display: block; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.hide-text-classic { | |
overflow: hidden; | |
text-indent: -9999px; | |
} | |
/* http://www.zeldman.com/2012/03/01/replacing-the-9999px-hack-new-image-replacement/ */ | |
.hide-text-zeldman { | |
overflow: hidden; | |
text-indent: 100%; | |
white-space: nowrap; | |
} | |
/* http://nicolasgallagher.com/another-css-image-replacement-technique/ */ | |
.hide-text-gallagher { | |
color: transparent; | |
font: 0/0 a; | |
text-shadow: none; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () {}()) // Crockford way | |
(function () {})() // Alternative | |
!function () {}() // Saves one byte |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<meta charset=utf-8> | |
<title>Best page ever</title> | |
<link rel=stylesheet href=css/master.css> | |
<div id=content> | |
Awww yeahhhhhhh | |
</div> | |
<script src=//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js></script> | |
<script src=js/main.js></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hello | |
hello === void 0 // Faster than testing type | |
// true | |
hello === a // 'a' is just the name of any variable that doesn't exist | |
// true | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment