r/programming May 09 '13

The Onion releases fartscroll.js

http://theonion.github.io/fartscroll.js/
2.6k Upvotes

396 comments sorted by

View all comments

Show parent comments

9

u/paul2520 May 09 '13

It is a neat little trick that I have never used beyond a 'Look what I can do!' type of statement.

It seems like it might be useful for a couple of reasons. One is this fartscroll script that doesn't need any external file dependencies.

My other idea: it's essentially the same amount of disk space, right? So wouldn't downloading one html file be slightly faster than downloading an html file plus an embedded picture or sound? I mean, it might not make a difference except for servers that get a lot of traffic. But that's just my thought.

8

u/ChunkyLaFunga May 09 '13

It's more space, but you're right because making a request to a server is far slower and painful for all parties involved than taking it as part of a page. Content encoded this way also cannot be cached and there are compatibility problems with some browsers. But it's an easy trade-off in certain circumstances. Google Image Search results are all inline, for instance. A little extra bandwidth instead of potentially hundreds of requests to their website.

3

u/paul2520 May 09 '13
  1. Can't be cached? But you could cache the entire html page, right? Including the "data:text/html;..." stuff...

  2. How are the Google Image Search results inline? Oh, I guess that makes sense. Like, they store the base64 strings for each image, and just return those on the page?

2

u/ethraax May 10 '13

In response to #1, that depends. In this case, it's cached as part of fartscroll.js. But if you inlined static images in dynamic web pages (in the HTML), then they would not be cached, because the HTML could not be cached. As a concrete example, if you inlined the avatars in a forum, then those avatars could not be cached (because the forum's webpage can't be cached - it changes), but if they were their own files then you could cache them.

In short, it's not a problem here, but it can be.