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
// Eliminate FOIT (Flash of Invisible Text) caused by web fonts loading slowly | |
// Using font events with Font Face Observer | |
var roboto = new FontFaceObserver('Roboto', { | |
weight: 400 | |
}); | |
observer.check().then(function () { | |
document.getElement.className += 'fonts-loaded'; | |
}); | |
// Load multiple fonts using a Promise |
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 myImg = document.querySelector('img'), | |
op = document.querySelector('output'); | |
op.innerHTML = "Computed width: " + | |
getComputedStyle(myImg).getPropertyValue('width') + | |
'<br>' + 'img.width: ' + | |
myImg.width + | |
'<br>' + 'getAttribute(width): ' + | |
myImg.getAttribute('width') + | |
'<br>' + 'img.naturalWidth: ' + |
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 myScript = document.createElement('script'); | |
myScript.src = 'http://code.jquery.com/jquery-2.1.4.min.js'; | |
myScript.onload = function() { | |
console.log('jQuery loaded.'); | |
}; | |
document.body.appendChild(myScript); |
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
<section class="slider"> | |
<div class="flexslider"> | |
<ul class="slides"> | |
<li><img src="http://imgur.com/..." alt=""></li> | |
<li><img class="lazy" data-src="http://imgur.com/..." alt=""></li> | |
<li><img class="lazy" data-src="http://imgur.com/..." alt=""></li> | |
<li><img class="lazy" data-src="http://imgur.com/..." alt=""></li> | |
<li><img class="lazy" data-src="http://imgur.com/..." alt=""></li> | |
</ul> | |
</div> |
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 togglePassword() { | |
let passwordInput = document.getElementById('txtPassword'); | |
if (passwordInput.type === 'password') { | |
passwordInput.type = 'text'; | |
} else { | |
passwordInput.type = 'password'; | |
} | |
} | |
(function () { |
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
body { | |
font-family: -apple-system, | |
BlinkMacSystemFont, | |
"Segoe UI", | |
Roboto, | |
Oxygen-Sans, | |
Ubuntu, | |
Cantarell, | |
"Helvetica Neue", | |
sans-serif; |
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 i = performance.now(); | |
yourFunction(); | |
performance.now() - i; | |
//Or make a helper function, like this: | |
function performanceTest(testFunction, iterations) { | |
'use strict'; | |
var sum = 0; | |
var start = performance.now(); | |
for (var i = 0; i < iterations; i++) { |
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
<link rel="preload" href="http://scottjehl.com/css-temp/slow.php" as="style" onload="this.rel='stylesheet'"> | |
<!-- Ref: http://filamentgroup.github.io/loadCSS/test/preload.html --> |
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
.nav-tab { | |
... | |
// instead of putting it on | |
border-right: 1px solid #424242; | |
&:last-child { | |
border-right: 0; // and then taking it off | |
} | |
// use CSS not() to only apply to the elements you want | |
&:not(:last-child) { | |
border-right: 1px solid #424242; |