212 points · by gorm · 10y ago · 90 comments
Opera seemed like the only browser vendor that truly championed next/prev.
I only do it now as a habit because of Opera - and, since switching to Chrome after Opera's nadir, for accessibility, regardless of whether screenreaders respect it. But I probably wouldn't know about it if not for Opera.
It's both wistful and aspirational to use them, because this is the way browsers were supposed to work - as was generally the case with most things Opera, of course.
edit: While looking for the addon at addons.mozilla, I find that it has been discontinued by Evernote: 'This add-on has been removed by its author.' https://addons.mozilla.org/en-GB/firefox/addon/clearly/
Anyone know of another addon that works similarly?
There are extensions/bookmarklets available for other browsers at https://www.readability.com.
Personally, I've been reading long form and paginated content using the readability Send to Kindle bookmarklet which works great.
Fewer webpages where this would be useful now for me. Most either have infinite scroll, or forums/comments are in a complex tree-structure instead of pages.
Neither are blogs. Granted, Medium is making a complete mess of the semantic web, but all the more reason for them to support a semantic standard that might guide hapless readers such as myself to find their way.
For the most part, the "change" that "obviates" the standard are developers writing shitty code with all kinds of JavaScript nonsense that wreak havoc on accessibility, load, and UX. It's a little like saying right-clicking and using the back button in the browser aren't needed anymore, because dumb new frameworks are breaking them. :)
Dear lord, I just remembered Twitter's hashbang urls. To this day, they still break my Pinboard bookmarks.
If it's not present we start, like opera did, analyzing links, which is a little messy.
But also consider websites such as forums that allow users to post custom HTML to a page. Although there is often some sanitisation, that often doesn't stretch to removing attributes from <a> tags. In those cases, it might be possible for a user to hijack the sequential links and make them point to some other website.
[1] https://www.w3.org/TR/html/links.html#sequential-link-types
The next keyword may be used with link, a, and area elements
of course it is allowed to put it in <link>. And if your badly sanitized HTML (which hopefully did strip the malicious onClick handler ;)) includes an <a rel="" href="">, are we sure that parsers will prefer the <link> in the header? Or will Google and others actively ignore the <a>, despite the standard allowing it on both? That would be useful to know.
For simple bots putting it in an easy-to-discover link in <head> might be good, but a search engine and a browser both have to parse the entire page anyways...
There's a whole lot of advantages that follow, but aren't quite reasons why (e.g. like a physical book, I don't need to read the page itself to figure out where the next page is), but it follows from applying the semantics of webpage (meta) data in a consistent manner.
(except for a CYOA book)
I don't know whether Google sends you there, or whether the site redirects you from the "view all" page to the first page, but the result is pretty annoying.
[1]: https://developer.github.com/guides/traversing-with-paginati...
[2]: https://github.com/backbone-paginator/backbone.paginator
I know there are a bunch of gotcha's to look out for
On the other hand, you could have an "articles" table and a "pages" table with the relationship:
articles 1 <--> 1..* pages
Each page's text is stored as a separate row in the "pages" table, along with the article ID and a page number. When a page is requested, only the page that matches the requested article's ID and the appropriate page number. The database schema here is more complex, but is likely to be more efficient.Whichever method you choose, the software will need to be able to transform the data between two formats: one suitable for the user interface, and one suitable for the database.
However you designed the UI, it would be possible to use either approach for the database. For example, suppose the UI used a single textarea and had a special notation for delimiting pages. For the first approach, the contents of the textarea can simply be stored in its own field. For the second approach, the software would take the contents of the textarea, split it into its individual pages, then store each page separately.
If the UI had separate textareas for each page, then for the first approach, the software combines the contents of the textareas and puts in delimiters. For the second approach, each textarea is mapped to their own database field.
I suppose some of combinations are easier for the programmer than others, but so long as the UI is designed to be easy to use, the user need never know how the article is actually represented in the database.
Essentially, once your rows are ordered, your next page is "rows > the last row on the previous page, limit <number of items to return>"
This has the fantastic benefit of being index-friendly, which OFFSET is not, and if you structure the URLs for the pages well, obvious what you're getting back. (e.g., if your records are by date, you might get /daily-reports?since=2015-01-04&limit=50 for the page that starts at 2015-01-04)
It's from an SQL site, but the concept is not specific to SQL. I'm working on an implementation of it for data stored in Mongo, at the moment.
limit = page_size
offset = (current_page - 1) * limit
For example, let's say you have a table with 1000 products in it, and you want to display page 3 with a page size of 50. Here's how you would write it: SELECT *
FROM products
LIMIT 50
OFFSET 100At which point you could assign each post in a topic an indexed `position` column that always increases from 0 within that topic, which lets you jump to arbitrary pages and parameterize perPage.
fromPos = (page - 1) * perPage
SELECT *
FROM posts
WHERE topic_id = $1
AND position >= fromPos
AND position < fromPos + perPage
ORDER BY id
For simpler needs, your "Next" button could load items that come after the last ID on the current page but with a LIMIT. <ul>
{% for item in items %}
<li>{{ item }}</li>
{% endfor %}
</ul>
<a href="/items?afterId={{ items[items.length - 1].id }}">Next</a>
SELECT *
FROM items
WHERE id > $afterId
LIMIT $perPage
That's fast and really easy.For NoSQL, specifically (only?) CouchDB, you start iterating from a given key (in SQL, this would effectively be "WHERE id >= $start ORDER BY id ASC LIMIT n").
This difference is why I would recommend, especially for paginated REST APIs, to provide links to the next/prev pages, so API clients can follow these links without thinking about how pagination is accomplished exactly. To prevent people from guessing the inner workings and working around your links, you can encode the parameters in a "cursor" (so instead of ?pagesize=20&page=10 you could have ?cursor=base64encode("20,10") (SQL) or ?cursor=base64encode("$startKey") (NoSQL)). IIRC Facebook does it this way. Encrypting or authenticating the cursor is IMHO overblown here, given cursor values can be easily validated and rejected if fiddled with.
Using an opaque cursor also gives you the ability to change how pagination works without breaking existing API clients.
If you plan for lots of data and many pages, think twice before outputting links to all pages (on a website) or outputting the total number of elements (in an API). COUNT(*) on InnoDB is slow and I heard it's not the quickest thing in NoSQL databases either.
http://use-the-index-luke.com/sql/partial-results/fetch-next...
edit: more on this via a slideshare presentation or pdf:
http://use-the-index-luke.com/blog/2013-07/pagination-done-t...
This is very efficient when your table is indexed by that field; you can seek directly to the next record.
Some database APIs do this for you!
I wrote up my experience implementing this on App Engine here, http://johntantalo.com/blog/paginating-with-bookmarks-in-app...
Forcing artificial page-breaks is abusive.
Yes, don't unnecessarily break up content. But most pages are going to include lists of some sort that you want to be paginated in some way.
If you look at HNs /new queue, there are submission IDs in the next links, so you can click "more" multiple times without seeing content multiple times, even if new submissions have pushed them down in the global list by now. Useful if there are many updates and new entries come in at the "top" of the list.
I sometimes hate it (e.g. in facebook because it bluntly breaks the scrollbar), but at other times I miss it (e.g. in gmail).
Similar is google maps. If you make it a large canvas where the missing data is paged in then it becomes quite natural.
- usually breaks the back button (e.g. scroll to the 20th page, click something, go back. welcome to page 1!)
- usually breaks links (how do you show someone things-on-page-10?) (fixable by tweaking the URL as you go, but nothing is really consistent + predictable by non-technical users)
- usually performs hideously on low-power machines (e.g. mobile) due to memory growth (there are techniques, but few use them). can even tank powerful machines in time.
- footers. headers. etc.
You will also end up losing your reading position after a browser restart or on iOS where Mobile Safari reloads a page to save memory.
It's a dumb, pointless feature that at the very least shouldn't be the default option. I'm sure there are hypothetical scenarios that may or may not warrant it, but it is a pain and a half for the user. Tumblr blogs have it in spades, and it's a miserable experience to browse.
Salient points seem to be:
# Update URL during scrolling so links don't break, and link to the "deep" item not just the first page.
# Don't break history, so back/forward/reload buttons act as would be expected.
# Truly endless scrolling kills browsers due to consuming increasing resources, so don't do it. Seems that a compromise might be: larger page sizes that lazy-load content up to a sensible max length. For example, in a data set of 1,000 results perhaps display the first 10 immediately and lazy-load up to 50 during scrolling. Then normal paging occurs. (Max items per page could be user-selected, as is currently seen sometimes.) Items that have scrolled off the top of the page could be removed from the DOM too, and lazily reloaded on demand.
# Endless scrolling is not always appropriate, but there may be appropriate use cases. It would be good to identify these cases, perhaps through user testing.
# Obviously, it shouldn't break screen readers or text-only browsers etc. These should be handled gracefully.... which raises the question of how to effectively navigate through a large list, possibly of unknowable length, in these browsers.
I feel sure I've seen various of these, but not all together in one implementation. Anyone seen somewhere that does all this well?
Any further suggestions/criticisms of this pattern?
I think I might start overriding the existing methods which users are used to with this method because I've build websites for a couple of years and think I know better than years of UI development by much more experienced people than I.