Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <h1>Infinite Scroll v4 - Loading JSON</h1>

<p>Loading photos from the <a href="">Unsplash API</a></p>

<div class="container"></div>

<div class="page-load-status">
  <div class="loader-ellips infinite-scroll-request">
    <span class="loader-ellips__dot"></span>
    <span class="loader-ellips__dot"></span>
    <span class="loader-ellips__dot"></span>
    <span class="loader-ellips__dot"></span>
  <p class="infinite-scroll-last">End of content</p>
  <p class="infinite-scroll-error">No more pages to load</p>



                body {
  font-family: sans-serif;
  line-height: 1.4;
  padding: 20px;
  max-width: 640px;
  margin: 0 auto;

.photo-item {
  margin: 40px 0;
  padding-top: 20px;
  border-top: 1px solid #DDD;

.photo-item__image {
  display: block;
  max-width: 100%;

.page-load-status {
  display: none; /* hidden by default */
  padding-top: 20px;
  border-top: 1px solid #DDD;
  text-align: center;
  color: #777;

/* loader ellips in separate pen CSS */



                // Get an API key for your demos at
const unsplashID = '9ad80b14098bcead9c7de952435e937cc3723ae61084ba8e729adb642daf0251';

let $container = $( '.container').infiniteScroll({
  path: function() {
    return `${unsplashID}&page=${this.pageIndex}`;
  // load response as JSON
  responseBody: 'json',
  status: '.scroll-status',
  history: false,

$container.on( 'load.infiniteScroll', function( event, body ) {
  // compile body data into HTML
  let itemsHTML = getItemHTML ).join('');
  // convert HTML string into elements
  let $items =  $( itemsHTML );
  // append item elements
  $container.infiniteScroll( 'appendItems', $items );

// load initial page


function getItemHTML({ user, urls }) {
  return `<div class="photo-item">
    <img class="photo-item__image" src="${urls.regular}" alt="Photo by ${}" />
    <p class="photo-item__caption">
      <a href="${user.links.html}?utm_source=infinite-scroll-demos&utm_medium=referral&utm_campaign=api-credit">${}</a>