Skip to content
HomeVideosBooksBlogs
AllTop postsTopics
Podcasts
HistoryListsWatch laterLiked videosFollowing

The videos, books, blogs and podcasts Hacker News keeps recommending, all in one place.

VideosBooksBlogsPodcastsAboutPrivacySettings

Data from Hacker News, HackerTube, HackerBooks, HackerBlogs and Open Library. Credits · Not affiliated with Y Combinator.

HomeVideosBooksBlogsPodcasts
Ctrl K
    B

    Ben Alman

    benalman.com · Personal blog · on HN since 2009

    Ben Alman, a JavaScript and jQuery developer, writes about JavaScript patterns, jQuery plugins and coding style.

    Visit blogHN submissions
    Web DevelopmentProgramming
    What HN says

    HN links it for his IIFE naming post, jQuery plugins such as postMessage and BBQ, a bookmarklet generator and his semicolon advice.

    Stats for nerds
    35HN people shared it
    20linked in comments
    128story points
    Sep 2017last shared
    2010people per year2017

    Top posts on HN

    1. 1
      JQuery BBQ: Back Button & Query Library
      5 people · 57 points · first shared 2010 · 3 comments on HN
    2. 2
      Immediately-Invoked Function Expression (2010)
      8 people · 23 points · first shared 2010 · 16 comments on HN
    3. 3
      Star-wizzity-wipe in Webkit
      1 person · 12 points · first shared 2009 · 5 comments on HN
    4. 4
      Multiple var statements in JavaScript, not superfluous
      2 people · 9 points · first shared 2012 · Discussion on HN
    5. 5
      There's no such thing as a "JSON Object"
      4 people · 7 points · first shared 2010 · 4 comments on HN
    6. 6
      JavaScript's Chuck Norris
      1 person · 7 points · first shared 2009 · Discussion on HN
    7. 7
      A Bit of Advice for the JavaScript Semicolon Haters
      3 people · 5 points · first shared 2013 · 1 comments on HN
    8. 8
      JQuery Special Events
      2 people · 2 points · first shared 2010 · Discussion on HN
    9. 9
      HN Bookmarklet to make all comments visible
      1 person · 2 points · first shared 2010 · 1 comments on HN
    10. 10
      Apparently, someone misses Makefiles
      1 person · 2 points · first shared 2013 · Discussion on HN

    What HN people wrote when they linked it

    • poFeb 2012

      This one bit me the other day and forced me to switch JavaScript compressors because the one I was using (it was python-based) didn't get the IIFE (http://benalman.com/news/2010/11/immediately-invoked-function-expression/) right when appending files together.

      In this blog posting Jacob writes:

      The majority of lines however don’t end with semicolons because they simply aren’t necessary and I prefer the minimalist aesthetic. For me, \n character is enough and the semicolon character is redundant.

      He then points to the izs blog posting about it:

      http://blog.izs.me/post/2353458699/an-open-letter-to-javascript-leaders-regarding

      Jacob calls it more 'minimalist' however it does require you to know (and think about) the rules of when Javascript accepts a newline as a line terminator and when it doesn't. In terms of cognitive minimalism 'semis-everywhere' wins. @izs even acknowledges that part of the advantage is forcing the developer to learn:

      To the extent that there is an objectively “better” choice, it appears to me that the minimal-semicolon/comma-first style is slightly superior, both because it is fundamentally more scannable and because it encourages programmers to better understand the language they use.

      and later:

      If you don’t understand how statements in JavaScript are terminated, then you just don’t know JavaScript very well, and shouldn’t write JavaScript programs professionally without supervision, and you definitely should not tell anyone else how to write…

    • keyistJun 2010

      Imo, the most important technique (besides standard ajax with js lib of choice) is making use of hashchange and organizing your behavior into 'routes' based on the hash. You'll notice that Gmail does this -- it has URIs ending with #inbox, #label/action, etc.

      Using hash routes allows you to keep track of state and decouple event handlers that set state from code that updates the page. Plus you get back button functionality and bookmark support.

      Some background info on hashchange: http://blog.whatwg.org/this-week-in-html-5-episode-3

      jquery library for dealing directly with hashchange: http://benalman.com/projects/jquery-bbq-plugin/

      Higher-level jquery library for handling hashchange: http://code.quirkey.com/sammy/ . It has more assumptions and imposes more constraints on the structure of your code. But in return you get route parsing and a DSL.

      If you go through the examples/tutorials in those two libraries you should gain enough knowledge to get started.

    • udpMay 2011

      It does work in FF4, but it's not widely supported enough to rely on just yet, you're right.

      I also find the best thing to do is use a hybrid approach (pushState where available, hashbang as a fallback.) If anyone else is interested in implementing this, there are some good frameworks[1][2] to give functionality similar to pushState via the fragment identifier.

      Note that these constantly poll the hash in browsers that don't support the onhashchange event. It's a good idea to turn down the polling frequency to half a second or so, because I've found it can cause performance problems in IE.

      [1] http://code.google.com/p/reallysimplehistory/

      [2] http://benalman.com/projects/jquery-bbq-plugin/

    • ZoFreXFeb 2011

      Yes, if I were forced to use JS for loading the primary content I would do that too. There are a couple of options for doing so if you don't want to roll your own (and you don't - it is actually a very complex thing to get working cross browser), JQuery History [1] which is nice and simple, and JQuery BBQ if you need a bit more control.

      Personally I think it's a little early for pushState, and degrading to #! is really ugly, so for now I would say just use normal page loads like everyone else unless you have a really good reason (good reason: GMail. bad reason: glorified blog.)

      [1] http://tkyk.github.com/jquery-history-plugin/
      [2] http://benalman.com/projects/jquery-bbq-plugin/

    • nullobjectSep 2014

      You're mostly right.

      The console var is assigned the result of an immediately-invoked anonymous function (http://benalman.com/news/2010/11/immediately-invoked-function-expression/).

      The result of this function is an object which contains the console functions (log, warn, error, etc). Moreover, these functions only exist inside the scope of the anonymous function, so the only way to access them is through the returned object. This prevents the global namespace from being polluted.

      So when you call console.log('hello'), you're applying one of those functions in the object returned by the anonymous function.

    • padolseyNov 2013

      I don't believe this is "the most practical explanation of closures out there" as the author claims, but it does present a use-case. The most important thing to grasp if you're fussed about naming concepts in JavaScript is the difference between a function, a scope [1], a closure [2], and an IIFE [3].

      [1] https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions_and_function_scope

      [2] http://unscriptable.com/2011/10/02/closures-for-dummies-or-why-iife-closure/

      [3] http://benalman.com/news/2010/11/immediately-invoked-function-expression/

    Related

    Ben Cherryadequatelygood.com27 people

    Writing Testable JavaScript

    Ben Cherry
    Personal · last shared 2023
    Steven Levithanblog.stevenlevithan.com18 people

    Regex Legends: The People Behind the Magic

    Steven Levithan
    Personal · last shared 2024
    Nihilogicblog.nihilogic.dk23 people

    Genetic algorithms, Mona Lisa and JavaScript + Canvas

    Nihilogic
    Personal · last shared 2014
    Isaac Schlueterblog.izs.me88 people

    A member of our community is missing, help find him

    Isaac Schlueter
    Personal · last shared 2026
    Ben Nadelbennadel.com82 people

    I've been merging microservices back into the monolith

    Ben Nadel
    Personal · last shared 2026
    DailyJSdailyjs.com112 people

    Backbone.js: Hacker's Guide

    DailyJS
    Publication · last shared 2017
    codeburst.iocodeburst.io174 people

    Google’s Flutter = React and Java Swing

    codeburst.io
    Publication · last shared 2023
    Vidar Holenvidarholen.net68 people

    Useless Use of "dd" (2015)

    Vidar Holen
    Personal · last shared 2025