16 Jun 2017

Breaking change in Forge Viewer.loadExtension

Default blog image

    The 2.15 version of the Forge Viewer released last week is introducing a small breaking change in the way viewer.loadExtension method returns its value. It's a very straightforward migration, so simply take a look at the snippets below. The development team introduced this change in order to support asynchronous loading of extensions: some of the Forge Viewer extensions will no longer be bundled with viewer3D.js (or viewer3D.min.js) but will be dynamically fetched from our server when required, so it will make the basic Viewer API lighter. 

The viewer.loadExtension method now returns a Promise, which is a nicer design pattern than mere callbacks, if you are not yet using them in your Web Application, now is a pretty good time to get on the band wagon... Happy Forge coding!

// 2.14 and below
// Synchronous code, WILL NO LONGER WORK in v > 2.14
var res = viewer.loadExtension('MyExtensionID')

if (res) {

  // extension successfully loaded
  var myExtension = viewer.getExtension('MyExtensionID')


// 2.15 and above - ES5

  function(myExtension) {


  }, function (err) {

    console.log('Error loading extension: ')

// 2.15 and above - ES6/async
try {

  const myExtension = await viewer.loadExtension(


} catch (ex) {

  console.log('Error loading extension: ')


Related Article