Skip to content

Instantly share code, notes, and snippets.

View arturparkhisenko's full-sized avatar
:octocat:
www. www always changes

Artur Parkhisenko arturparkhisenko

:octocat:
www. www always changes
View GitHub Profile
@arturparkhisenko
arturparkhisenko / break-word.sass
Created October 18, 2015 17:30 — forked from akella/break-word.sass
Breaking long words
=force-new-lines-for-long-words
-ms-word-break: break-all
word-break: break-all
word-break: break-word
-webkit-hyphens: auto
-moz-hyphens: auto
hyphens: auto
@arturparkhisenko
arturparkhisenko / js-overwrite-back-button.js
Created October 20, 2015 18:48
overwrite-back-button-history-api
//source https://stackoverflow.com/questions/6359327/detect-back-button-click-in-browser
window.onload = function() {
if (typeof history.pushState === "function") {
history.pushState("jibberish", null, null);
window.onpopstate = function() {
history.pushState('newjibberish', null, null);
// Handle the back (or forward) buttons here
// Will NOT handle refresh, use onbeforeunload for this.
};
} else {
const prefetch = document.createElement('link');
prefetch.setAttribute('rel', 'prefetch');
prefetch.setAttribute('href', url);
document.head.appendChild(prefetch);
// http://mattiaswallander.com/blog/2014/06/23/fps-counter-for-firefox/
(function() {
var overlay, lastCount, lastTime, timeoutFun;
overlay = document.createElement('div');
overlay.style.background = 'rgba(0, 0, 0, .7)';
overlay.style.bottom = '0';
overlay.style.color = '#fff';
overlay.style.display = 'inline-block';
overlay.style.fontFamily = 'Arial';
@arturparkhisenko
arturparkhisenko / preconnect.js
Created November 17, 2015 14:28 — forked from cramforce/preconnect.js
link rel preconnect polyfill
const url = origin + '/amp_preconnect_polyfill?' + Math.random();
const xhr = new XMLHttpRequest();
xhr.open('HEAD', url, true);
xhr.send();
@arturparkhisenko
arturparkhisenko / mediator_trim.js
Created December 10, 2015 07:49 — forked from addyosmani/mediator_trim.js
Mediator revisited
//trimmed down version of jack lawsons mediator
(function (root) {
// We'll generate guids for class instances for easy referencing later on.
// Subscriber instances will have an id that can be refernced for quick
// lookups.
function guidGenerator() {
var S4 = function () {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
@arturparkhisenko
arturparkhisenko / js-module-es5.js
Last active December 11, 2015 22:03
js-module-es5 (Node.js|CommonJS / AMD / Default to window as global)
(function(exports) {
'use strict';
function foo() {}
// Node.js|CommonJS / AMD / Default to window as global
if (typeof module !== 'undefined' && module.exports) {
module.exports = exports = foo;
} else if (typeof define === 'function' && define.amd) {
define(function() {
@arturparkhisenko
arturparkhisenko / webComponentsSupported.js
Last active January 22, 2016 18:00
webComponentsSupported polyfill
// 4. Conditionally load the webcomponents polyfill if needed by the browser
function finishLazyLoading() {
window.Polymer = window.Polymer || {
dom: 'shady' //'shadow'
};
// 6. Fade splash screen, then remove.
var onImportLoaded = function() {
var loadEl = document.getElementById('splash');
@arturparkhisenko
arturparkhisenko / browserInfo.js
Last active January 22, 2016 18:09
Browser-and-OS-detect
function BrowserInfo() {
this.supported = false;
this.isBrowser = true;
this.webBrowser = null;
this.webBrowserVer = null;
this.os = 'unknown os';
var detectedUA = null;
if (typeof window === 'undefined' || !window.navigator) {
@arturparkhisenko
arturparkhisenko / perf-scroll-tip.js
Last active January 29, 2016 17:36
perf-scroll-tip
let body = document.body;
let timer;
window.addEventListener('scroll', () => {
clearTimeout(timer);
if (!body.classList.contains('disable-hover')) {
body.classList.add('disable-hover');
}
timer = setTimeout(() => {
body.classList.remove('disable-hover');
}, 500);