Migrating from Owl Carousel Version 1 to Version 2

Laptop with a split code editor comparing version 1 options on the left with version 2 options on the right

Version 2 of Owl Carousel was a substantial rewrite rather than an incremental update. The markup remains familiar, but many option names, the responsive system, the stylesheets and the way scripts control the carousel all changed. This guide maps the differences so an upgrade can proceed methodically.

Why Migrate at All

Version 1 still functions on many sites, so the case for migrating deserves a clear statement. Version 2 introduced features that version 1 lacks, including genuine infinite looping with clones, centre mode, automatic widths, built-in video support, URL hash navigation and a richer set of events. It also uses CSS3 transforms more consistently, which improves smoothness on modern devices, and it is the version documented by the official site and distributed through npm and cdnjs.

There are also practical reasons. New developers joining a project are far more likely to know version 2, and most examples published online target it. Remaining on version 1 means translating every answer found elsewhere, which slowly increases the cost of maintenance.

Before You Start

Make a list of every page that uses the carousel and note the options each instance passes. Upgrading one instance at a time, with the old and new files kept in separate folders, makes problems far easier to isolate. Remember that version 2 recommends jQuery 1.8.3 or later, whereas version 1 worked with 1.7.

Replacing the Files

Version 1 shipped owl.carousel.css, owl.theme.css and owl.transitions.css. Version 2 replaces these with owl.carousel.min.css and a choice of theme files such as owl.theme.default.min.css. The transitions stylesheet no longer exists; animations are handled through the animateIn and animateOut options.

Option Mapping

Version 1Version 2
items, itemsDesktop, itemsTablet, itemsMobileresponsive object keyed by minimum width
singleItem: trueitems: 1
navigationnav
navigationTextnavText
paginationdots
autoPlay (true or milliseconds)autoplay plus autoplayTimeout
stopOnHoverautoplayHoverPause
slideSpeedsmartSpeed
rewindNavrewind
scrollPerPageslideBy: "page"
transitionStyleanimateOut and animateIn
lazyLoad with class lazyOwllazyLoad with class owl-lazy

Converting Responsive Settings

Version 1 expressed breakpoints as maximum widths in arrays such as itemsTablet: [768, 2]. Version 2 uses minimum widths in an object. Translate each array by adding one pixel to the width and moving it to the next range up:

// Version 1
items: 4,
itemsTablet: [768, 2],
itemsMobile: [479, 1]

// Version 2
responsive: {
  0:   { items: 1 },
  480: { items: 2 },
  769: { items: 4 }
}

Callbacks and Methods

Version 1 callbacks such as afterMove and beforeMove become event listeners or on-prefixed options in version 2, for example onTranslated and onTranslate. Direct method calls change as well. Code that previously retrieved the instance and called a method now triggers a namespaced event:

// Version 1
var owl = $("#owl").data("owlCarousel");
owl.next();
owl.goTo(3);

// Version 2
$("#owl").trigger("next.owl.carousel");
$("#owl").trigger("to.owl.carousel", [3]);

Markup and Theme Classes

Add the class owl-theme to each carousel container if you rely on the default theme, since version 2 applies theme styles through that class. Review any custom CSS that targets version 1 selectors such as .owl-controls .owl-buttons div; version 2 renders controls inside .owl-nav and .owl-dots as button elements.

Testing the Result

  • Compare item counts at each breakpoint against the original layout.
  • Check that autoplay timing and hover pausing match previous behaviour.
  • Confirm lazy-loaded images use the new class name.
  • Verify that any script counting items accounts for clones when looping.

Updating Custom CSS Selectors

Version 2 renamed the elements it generates, so any stylesheet written for version 1 needs its selectors updated. The most common replacements are these:

Version 1 selectorVersion 2 selector
.owl-wrapper-outer.owl-stage-outer
.owl-wrapper.owl-stage
.owl-controls .owl-buttons .owl-prev.owl-nav .owl-prev
.owl-controls .owl-buttons .owl-next.owl-nav .owl-next
.owl-pagination.owl-dots
.owl-pagination .owl-page span.owl-dots .owl-dot span

The class .owl-item keeps its name, and version 2 adds useful state classes to it, such as active for visible items, cloned for loop clones and center in centre mode.

Version 1 and Version 2 Cannot Share a Page

Both versions register themselves under the same jQuery method name, owlCarousel. Whichever script loads last replaces the other, so you cannot run old and new carousels side by side on a single page. Migrate page templates one at a time instead, loading only the version each template requires.

Upgrading jQuery at the Same Time

Projects that still use version 1 often run an old release of jQuery as well. If you upgrade jQuery during the migration, load the jQuery Migrate script temporarily. It restores many removed features and logs a console warning each time one is used, giving you a clear list of other code that needs attention. Remove it once the warnings stop appearing.

A Migration Checklist

  1. Record every page and the options each carousel uses.
  2. Replace the version 1 scripts and stylesheets with the version 2 files.
  3. Add owl-theme to each container that relies on the default theme.
  4. Translate option names using the mapping table.
  5. Convert maximum-width breakpoint arrays into a responsive object.
  6. Replace callbacks with events and method calls with triggered events.
  7. Rename lazyOwl image classes to owl-lazy.
  8. Update custom CSS selectors.
  9. Test each page on phones, tablets and desktops before moving to the next.

Key Takeaways

  • Version 1 and version 2 cannot run on the same page.
  • Translate options with the mapping table and breakpoints to minimum widths.
  • Replace method calls with triggered events.
  • Update custom CSS selectors for the new element names.

Summary

Swap the files, translate the options using the table above, convert breakpoints to minimum widths and replace direct method calls with triggered events. Working through each instance in turn keeps the upgrade manageable.