Skip to content

Instantly share code, notes, and snippets.

@kixxauth
Created January 12, 2013 18:07
Show Gist options
  • Save kixxauth/4519653 to your computer and use it in GitHub Desktop.
Save kixxauth/4519653 to your computer and use it in GitHub Desktop.
Avoid parsing JavaScript on older devices. From https://m.lanyrd.com/
<head>
<script>
(function() {
var d = document,
w = window,
de = d.documentElement,
os = w.applicationCache && w.JSON && w.localStorage,
om = window.operamini,
pe = 'pointerEvents' in de.style && !window.opera, // Opera gives false positive
bs = 'backgroundSize' in de.style && !om; // Opera Mini gives false positive
if (w.doneIntro) return;
// Dirty and you love it - this really speeds up ancient devices, avoids bulk of js parsing
w.preventScript = om || !os;
w.isAppCacheRoot = !0;
w.doneIntro = !0;
de.className+= (preventScript ? '' : ' js')
+ (os ? ' offline-support' : '')
+ (pe ? ' pointer-events-support' : '')
+ (de.addEventListener ? ' bubbling-support' : '')
+ (bs ? ' background-size-support' : '')
+ ('placeholder' in d.createElement('input') ? ' placeholder-support' : '');
w._gaq=[['_setAccount','UA-18148195-5'],['_trackPageview']];(function(t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)}('script'))
// Add a class to images that fail/load
function il(className) {
return function(event) {
var t = event.target;
if (t.nodeName === 'IMG') t.className += className;
}
}
if ( de.addEventListener ) {
de.addEventListener( 'error', il(' img-failed'), true);
de.addEventListener( 'load', il(' img-loaded'), true);
}
})();
</script>
<link rel="stylesheet" href="/all.6e000fcd.css">
<meta name="apple-itunes-app" content="app-id=467652813" app-argument="lanyrd:/">
</head>
<body>
<script>preventScript && document.write("<!"+"--")</script>
<script src="https://s3.amazonaws.com/static.lanyrd.net/mobile-web-bundle.95f2235b.gz.js"></script>
<script src="/templates.v341.js"></script>
<!---->
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment