Skip to content

Instantly share code, notes, and snippets.

@blakeyoder
Last active July 30, 2018 14:47
Show Gist options
  • Save blakeyoder/c394982e0816b981f556fa131e8c49f4 to your computer and use it in GitHub Desktop.
Save blakeyoder/c394982e0816b981f556fa131e8c49f4 to your computer and use it in GitHub Desktop.
Code Snippets -- tired of re-googling everything

jQuery


event delegation

Should all jQuery events be bound to $(document)?

overflowing element

Script to determine which elements are creating a horizontal overflow (creating an unnecessary scrollbar)

var all = document.getElementsByTagName("*"), i = 0, rect, docWidth = document.documentElement.offsetWidth;
for (; i < all.length; i++) {
    rect = all[i].getBoundingClientRect();
    if (rect.right > docWidth || rect.left < 0){
        console.log(all[i]);
    }
}

es6

fat arrow functions

https://hackernoon.com/getting-to-grips-with-es6-arrow-functions-ebfa62c5c5d6 img

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment