• IE9 Stylesheet Not Loading Due to Case Sensitivity

    ie-devil_03

    I recently discovered something very dastardly about IE9 (and possibly other versions – I haven’t tested them all): class names are case sensitive in IE9. In other words, if your HTML looks something like this:

    ...
    <div class = "MyDiv"></div>
    ...
    

    And your CSS looks something like this:

    .myDiv {
    /* Styles Here */
    }
    

    Read more

  • Helpful Tools For Web Developers: JSON Generator

    jsongenerator

    If you’re looking for a really cool tool for generating JSON data for your web applications, check out the JSON generator. The JSON generator is a web app that let’s you quickly and easily generate very complex JSON data structures to whatever scale your application needs. From the website:

    Read more

  • Code Snippet: Prevent Flickering When Enforcing Maxlength on Textareas

    keypress

    I was doing some research today regarding how to limit the number of characters on the page while removing the annoying flickering effect that often occurs with JavaScript-based solutions to the problem. Here’s what I came up with:
    Read more

  • A Helpful Guide to Moving Away From jQuery (Via the Lonely Coder)

    moving truck

    Recently, I wrote a post about how jQuery’s prevalence on the web was causing web developers to learn less JavaScript and more jQuery due to how it conceals many of the more complicated inner workings of JavaScript in wrapper methods like bind and ready.

    Michael Enger over at The Lonely Coder seems to agree with me and he put together a really cool guide on how to replace some of the more common jQuery methods with their native JavaScript counterparts. In addition to going over how to replace ready and how to do event delegation, he does an excellent job of covering CSS selectors. From the guide:

    One of the greatest benefits of jQuery is to be able to drill down into the DOM by using CSS-style selector strings to specify which element you’re looking for. Something as complicated as “#app ul .title a:hover > span.left” can be used to choose one specific element, or a set of elements that are situated in various places around the document. Unfortunately there isn’t a direct replacement in native JavaScript, but a combination of getElementById, getElementsByTagName and getElementsByClassName, as well as iterating through the results, can be used to select the element(s) you need and not being able to rely on CSS pseudo-classes or some of the more esoteric selectors may result in structuring the HTML in a less convoluted way, avoiding unnecessary strain on the browser who has to deal with all your crazy shenanigans.

    // Get the data-foo attribute of all links inside a .button list
    var buttons = document.getElementsByClassName('buttons'),
        foo = '';
    for (var i = 0; i < buttons.length; i++) {
        var links = buttons[i].getElementsByTagName('a');
        for (var j = 0; j < links.length; j++) {
            var link = links[j];
            foo += link.attributes['data-foo'];
        }
    }
    

    Edit: My good friend Torjus Bjåen made me aware of the querySelectorAll function, which provides the same CSS-style selector capabilities that jQuery does, albeit without some of the more “magical” selectors. It works like you’d expect and can be used to easily fetch elements that may be spread about the DOM.

    var links = document.querySelectorAll('.buttons a.special');
    for (var i = 0; i < links.length; i++) {
        links[i].style.backgroundColor = '#f09';
    }
    

    I highly suggest you check out his guide, it’s an excellent starting place for those looking to move away from jQuery and to a more native approach.

  • Recommended Reading: How to Think Like a Programmer

    think like a programmer

    Recently, I began working on improving my problem solving skills as a programmer. Usually, this is done by trying to solve a series of increasing difficult puzzles. No, I’m not talking about the rumored Microsoft and Google questions of “How do you move Mount Fuji?” and “How many golf balls can fit in a school bus?” True programming puzzles (at least ones worth solving) are designed to exercise and evaluate your critical thinking skills. One great book for helping increase these skills is Think Like a Programmer: An Introduction to Creative Problem Solving by V. Anton Paul.

    Read more

  • Why Array.Splice Belongs With Push, Pop, Shift, and Unshift

    If you take a look at tutorials about JavaScript adding and removing items from an array, you’ll see four methods mentioned: Push, Pop, Shift, and Unshift. If you’re new to JavaScript or need a refresher, here’s a quick breakdown of each of those methods.

    Push

    Definition: Mutates an array by appending the given elements and returning the new length of the array. This method changes the length of the array.

    Read more

  • How to “Detect” If Your CDN is Down And Load a Script Locally As Backup

    system down

    I’m sure this has been around for a while now, but I just stumbled upon it and found it interesting:

    ...
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script>
    window.jQuery || document.write('<script src="js/vendor/jquery-1.9.1.min.js"><\/script>')</script>
    ...
    

    Basically, this does a check to see if jQuery has loaded properly from the CDN and, if it hasn’t, it tries to load it locally.

  • Semicolon Insertion: Or Why You Should Keep Braces on the Same Line

    When it comes to code formatting, developers can be pretty opinionated. Some believe in tabs while others like to use spaces. Some people believe the else statement should go on the same line as the closing brace of the if and some people think the else should go on the same line.

    Read more

  • Helpful Tools for Web Developers: TryRuby.org

    why's guide

    If you’re looking for an interactive way to mess around with Ruby without installing anything, I’d checkout TryRuby.org. It’s a really cool interactive terminal that let’s you execute ruby commands from the comfort of your browser. You can even step through a quick 15 minute tutorial inspired by Why’s Guide to Ruby.

  • Helpful Tools for Web Developers: Ruby Fiddle

    ruby fiddle

    Recently, I talked about my desire to learn more Ruby to help round out my skill set. Well, if you’ve ever taken up the task of learning a new language, you know that the most difficult part can be getting the proper development environment up and running, especially if you’re trying to run an open source language on a Windows platform. If you’re looking to start messing around with Ruby with out having to install anything, I recommend you check out Ruby Fiddle. It’s basically JsFiddle for Ruby developers and it’s a great way to both tinker with Ruby code and execute some of the examples in the Ruby Koans project I mentioned in an earlier post.

    As I’ve messed around with it, I have found a couple of weird issues. First, it appears that the “gistify” button doesn’t work as expected. Second, there’s no way for me to login and save the “fiddles” I make (JsFiddle allows you to do this). Hopefully these issues get fixed soon.