Results for "examples"

Tags

    • Kyle

      $id() - Shortened document.getElementById()

      Taken from https://websemantics.uk/archived/useful-javascript-functions/ "Saves repeatedly writing out document.getElementById('id'). Results are cached which speeds up repeat requests by 50%." I really like this one, credit to Mike Foskett @ websemantics.uk! 

      Tags: examples, websemantics.uk, $id(), document.getElementById()

      • Kyle

        Cookies

        Taken from https://www.webhostingsecretrevealed.net/blog/featured-articles/15-cool-javascript-sample-snippets/ "This snippet is a little long but very useful, it will allow your site to store information on the viewer’s computer then read it at another point in time. This snipp...

        Tags: examples, cookies, webhostingsecretrevealed.net

        • Kyle

          Polling

          Taken from https://davidwalsh.name/essential-javascript-functions "...sometimes you don't get to plug into an event to signify a desired state -- if the event doesn't exist, you need to check for your desired state at intervals. Polling has long been useful on the web and wil...

          Tags: examples, polling, davidwalsh.name

          • Kyle

            Get absolute URL

            Taken from https://davidwalsh.name/essential-javascript-functions "Getting an absolute URL from a variable string isn't as easy as you think. There's the URL constructor but it can act up if you don't provide the required arguments (which sometimes you can't). Here...

            Tags: examples, URL, davidwalsh.name

            • Kyle

              Applying styles to selectors - insertRule()

              Taken from https://davidwalsh.name/essential-javascript-functions "...we can grab a NodeList from a selector (via document.querySelectorAll) and give each of them a style, but what's more efficient is setting that style to a selector (like you do in a stylesheet)... This is espec...

              Tags: examples, CSS, davidwalsh.name

              • Kyle

                Debounce

                Taken from https://davidwalsh.name/essential-javascript-functions "The debounce function can be a game-changer when it comes to event-fueled performance. If you aren't using a debouncing function with a scroll, resize, key* event, you're probably doing it wrong. Here's a ...

                Tags: examples, debounce, davidwalsh.name

                • Kyle

                  Run once

                  Taken from https://davidwalsh.name/essential-javascript-functions "There are times when you prefer a given functionality only happen once, similar to the way you'd use an onload event... ...The once function ensures a given function can only be called once, thus preventing duplic...

                  Tags: examples, runonce, davidwalsh.name