Easily one of the worst front-end web failure modes I’ve ever seen, apparently caused by Ghostery blocking access to gapi, which is completely unnecessary for reading the article
Easily one of the worst front-end web failure modes I’ve ever seen, apparently caused by Ghostery blocking access to gapi, which is completely unnecessary for reading the article
The new papaparse.com is one of the best open source library websites I’ve ever seen. Going to be referring to this pattern in the future.
@kylewm good plan! I made some stuff which might be of interest:
define()
call on waterpigs.co.uk/js/app.jsPerfect little jQuery-free drag+drop sorting library: rubaxa.github.io/Sortable #js #bookmark
Javascript has no real Set or Dictionary implementation, which for someone spoiled by python’s set
and dict
s is rather frustrating. However, in leiu of the poorly supported js Set
type, plain old objects can be massaged into acting as both sets and dicts:
// Python: d = dict()
var d = {};
// d['key'] = 'value'
d['key'] = 'value';
// d.get('nonexistent', 'fallback')
d.hasOwnProperty('nonexistent') ? d['nonexistent'] : 'fallback';
// d.keys()
Object.keys(d);
// s = set()
var s = {};
// s.add(1)
s[1] = true;
// 1 in s
s.hasOwnProperty(1);
// Accessing all values in set:
Object.keys(s);
Notes: the in
operator can be used to test membership, but will incorrectly return true for __proto__
, as well as all properties up the prototype chain, i.e. all properties and methods of Object
. hasOwnProperty
is much safer to use.
Similarly, the use of the ternary operator for get-item-with-fallback could in theory be replaced with d['item'] || 'fallback'
, unless of course the value stored was falsey, in which case the or will incorrectly return a truthier fallback.
Just implemented notifications in #taproot! I get a native, first-class notification when I’m mentioned. Really easy to do with the notification API: developer.mozilla.org/en-US/docs/Web/API/notification
Update: demo video!
Not shown: clicking on the notification navigates to the source of the mention.
papaparse.com is a fantastic jQuery plugin for reading CSV files in #js — perfect for tiny feedback loop live previews of file uploads
My apologies to the @mozilla staff manning the FF Nightly bug reports today, for the stream of gradually less coherent “FF crashes when I drag leafletjs.com maps around whilst making HTTP requests” reports.
Had many basic software development lessons hammered in by personal experience over the last couple of years: hierarchy bad. side effects bad. many moving parts bad. undue complexity bad. inconsistency bad. SQL databases fragile. always be reducing.
It’s amazing just how seductive complex, unproductive tools can be. Successfully overcome+abandoned:
PHP remains productive and speedy (with composer, delightful dependency management), python nice with some irritations. jQuery useful when absolutely necessary, plain #js with small libraries loaded via requirejs handle most progressive enhancement concisely. node.js nice for some things, preferring go’s approach to async programming but still not much everyday need for it.
Avoiding middlemen: LESS, SASS, Coffeescript. Unnecessary for most of my work, and more moving parts is bad.
Now bothering me is the frameworky nonsense accumulating in #taproot. Need to cleanse.
jQuery and jQuery UI are amazing tools. They shouldn’t be used everywhere by default, but they do allow some complex stuff to be made extremely fast.
This evening: documented Yahoo! Pipes UI in case of sudden shutdown, built first mockup of web dataflow UI using jsplumbtoolkit.com — really excellent library, exactly the right balance between functionality and framework. It gives you a lot but doesn’t dictate how to use it.
Facebook use shady javascript to replace legit-looking link URLs with their own tracking endpoint.
I made a browser extension which removes this: facebook-anticlickjack.
It uses javascript to remove javascript from what should just be HTML. I call it “aggressive degredation”.
Why not to make assumptions about where your site visitors come from send #js to do a hyperlink’s job:
(That link didn’t work, obv)
And the #js lesson of the day is: bean.fire(el, 'click')
doesn’t work in Firefox Nightly, but turns out it’s unnecessary, because HTMLElement.click()
does exactly the same thing and already works cross-browser. Always use the browser-native APIs if you can.
My take on generic prev/next controls on keyup, using only bean for events, based on previous work by Aaron Parecki and Tantek Çelik:
// Generic prev/next navigation on arrow key press
bean.on(document.body, 'keyup', function (e) {
var prevEl, nextEl;
if (document.activeElement !== document.body) return;
if (e.metaKey || e.ctrlKey || e.altKey || e.shiftKey) return;
if (e.keyCode === 37) {
prevEl = document.querySelector('[rel~=previous]');
if (prevEl) bean.fire(prevEl, 'click');
} else if (e.keyCode === 39) {
nextEl = document.querySelector('[rel~=next]');
if (nextEl) bean.fire(nextEl, 'click');
}
});
Bookmarklet of the day: jsgif for giving GIFs controls. Pause, skip, reverse — it’s all there and not too slow either!
Just in case anyone was wondering, the “HA HA HA SOUP” bookmark in those gifs is this bookmarklet:
document.createTreeWalker
is actually pretty great.
Noflo flow based dev environment — YES YES YES YES YES THIS NEEDS TO EXIST #bookmark #programming #js
Trying to think of a good reason to make a #js library called bach.js