Skip to content

Instantly share code, notes, and snippets.

@brianleejackson
Created March 1, 2023 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianleejackson/c199f4e7b3882b3c79434f6c918e086e to your computer and use it in GitHub Desktop.
Save brianleejackson/c199f4e7b3882b3c79434f6c918e086e to your computer and use it in GitHub Desktop.
Only load FastClick on mobile devices (no tablets or desktop)
<script>
if (window.innerwidth < 900) {
document.write('<script type="text/javascript" src="https://domain.com/wp-content/plugins/perfmatters/vendor/fastclick/fastclick.min.js"><\/script>');
}
</script>
<script>
if(window.innerWidth < 900) {
if('addEventListener' in document) {
document.addEventListener('DOMContentLoaded', function() {
FastClick.attach(document.body);
}, false);
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment