Top all-time · #2207
Ben Alman
Personal blog · benalman.com/newsprogrammingweb
Ben Alman's personal blog at benalman.com covers programming and web. Since 2009, 35 different Hacker News readers have linked it 39 times, most often “Ben Alman » Immediately-Invoked Function Expression (IIFE)”. The last post was in 2013, but the archive is still widely read.
Too few sampled comments (19) to say how often HN recommends it.?
Why HN links it
HN readers link Ben Alman's blog and jQuery plugin pages on JavaScript techniques such as IIFEs, hash-based routing, postMessage, bookmarklets and throttling. Mostly cited as references.
Summarised by Claude from a sample of 19 HN comments that link here. Each comment is marked recommending, critical or neutral (citing without judging); how this works.
Most-linked posts?
- Ben Alman » Immediately-Invoked Function Expression (IIFE)7 people · 7 mentions · first linked 2010-11-28
- JQuery BBQ: Back Button & Query Library5 people · 5 mentions · first linked 2010-04-09
- A Bit of Advice for the JavaScript Semicolon Haters3 people · 3 mentions · first linked 2013-01-22
- /code/test/jquery-run-code-bookmarklet/3 people · 3 mentions · first linked 2010-05-24
- There's no such thing as a "JSON Object"3 people · 3 mentions · first linked 2010-10-09
- JQuery Special Events2 people · 2 mentions · first linked 2010-04-18
What Hacker News says?
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 rea…
Comment linking /projects/jquery-bbq-plugin/
on “Breaking the web with hash-bangs”Submitted JQuery BBQ: Back Button & Query Library as a story · 57 points
HN discussionOnly evil people put their return value on a second line... Regardless: http://blog.izs.me/post/2353458699/an-open-letter-to-javascr... Although to be fair: http://benalman.com/news/2013/01/advice-javascript-semicolon...
Comment linking /news/2013/01/advice-javascript-semicolon-haters/
on “How to Become a Great JavaScript Developer”Submitted Immediately-Invoked Function Expression (2010) as a story · 17 points
HN discussionI've been looking for some real-world examples of how currying might be useful in javascript. Haven't not used a language which supports currying for any real world project, I'm interested to know how it can help. I found a page [1] which talks about currying in javascript, then says "Are there practical uses for currying in JavaScript? Not really." Can you point me at anything which will help me see why it's useful…
Comment linking /news/2012/09/partial-application-in-javascript/
on “Lodash v3.0.0”Submitted Star-wizzity-wipe in Webkit as a story · 12 points
HN discussionYou can do it with IFRAME and postMessage communication. (Have the internal IFRAME send out resize data, and that's all you need to handle from the host page.) http://benalman.com/code/projects/jquery-postmessage/example...
Comment linking /code/projects/jquery-postmessage/examples/iframe/
on “Every Major Advertising Group Is Blasting Apple for Blocking Cookies in Safari”Submitted Multiple var statements in JavaScript, not superfluous as a story · 7 points
HN discussion- po · 2012-02-13
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-functio... ) 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.…
Comment linking /news/2010/11/immediately-invoked-function-expression/
on “Bootstrap's maintainer hates the semicolon” Submitted JavaScript's Chuck Norris as a story · 7 points
HN discussionI believe you can use partial() from this post[1] to do something like this: var processT1 = (isOk, items) => items.filter(isOk).map(toOtherType).flatten(); var processT2 = partial(processT1, isOk); http://benalman.com/news/2012/09/partial-application-in-java...
Comment linking /news/2012/09/partial-application-in-javascript/
on “Trine – A utility library for functional programming in JavaScript”Submitted There's no such thing as a "JSON Object" as a story · 5 points
HN discussionIt's just a regular JS object. JSON !== JavaScript object notation. E.g. according to the JSON spec, you should always quote property names (`{"foo":123}`) but regular JS doesn't require this (`{foo:123}`). More: http://benalman.com/news/2010/03/theres-no-such-thing-as-a-j...
Comment linking /news/2010/03/theres-no-such-thing-as-a-json/
on “Adobe Launches "Adobe Edge" - HTML5 Animation Tool”Submitted A Bit of Advice for the JavaScript Semicolon Haters as a story · 3 points
HN discussionImo, 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 functi…
Comment linking /projects/jquery-bbq-plugin/
on “How can I write an interface like Gmail?”Submitted Ben Alman » Immediately-Invoked Function Expression (IIFE) as a story · 3 points
HN discussionIt 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 th…
Comment linking /projects/jquery-bbq-plugin/
on “Its About The Hashbangs”Submitted Apparently, someone misses Makefiles as a story · 2 points
HN discussionInstead of polling, you can define event handlers for <script>'s onload and onreadystatechange event to detect when jQuery gets loaded. See Ben Alman's jQuery bookmarklet generator for an example: http://benalman.com/code/test/jquery-run-code-bookmarklet/
Comment linking /code/test/jquery-run-code-bookmarklet/
on “Implementing bookmarklets in JavaScript”Submitted A Bit of Advice for the JavaScript Semicolon Haters as a story · 2 points
HN discussionLet's see if HN allows this long link directly to the generated bookmarklet: http://benalman.com/code/test/jquery-run-code-bookmarklet/?n...
Comment linking /code/test/jquery-run-code-bookmarklet/?name=Quora+Bookmarklet&
on “Chrome extension lets you read Quora without logging in”Submitted Multiple var statements in JavaScript, not superfluous as a story · 2 points
HN discussionI found this great little jQuery bookmarklet generator from Ben Alman: http://benalman.com/code/test/jquery-run-code-bookmarklet/ You can just paste this code in and generate yourself a bookmarklet to reveal the quora answers (should work on all browsers). $('.blurred_answer_wrapper').removeClass('blurred_answer_wrapper'); $('.with_signup').removeClass('with_signup'); $('.signup_cta_on_answer').remove();
Comment linking /code/test/jquery-run-code-bookmarklet/
on “Chrome extension lets you read Quora without logging in”Submitted Immediately-Invoked Function Expression (IIFE) as a story · 2 points
HN discussionI use this JQuery Bookmarklet Creator all the time: http://benalman.com/code/test/jquery-run-code-bookmarklet/
Comment linking /code/test/jquery-run-code-bookmarklet/
on “Make Your Own Bookmarklets With jQuery”Submitted HN Bookmarklet to make all comments visible as a story · 2 points
HN discussionI 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/Referen... [2] http://unscriptable.com/2011/10/02/closures-…
Comment linking /news/2010/11/immediately-invoked-function-expression/
on “Understand closures”Submitted There's no such thing as a “JSON Object” (2010) as a story · 1 points
HN discussionI thought binding to window.scroll was considered bad practice without something like this http://benalman.com/projects/jquery-throttle-debounce-plugin...
Comment linking /projects/jquery-throttle-debounce-plugin/
on “StickyMojo: A contained sticky sidebar plugin for jQuery.”Submitted Multiple var statements in JavaScript, not superfluous (2012) as a story · 1 points
HN discussion