{"id":8641,"date":"2015-11-26T12:15:59","date_gmt":"2015-11-26T10:15:59","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=8641"},"modified":"2015-11-18T20:19:41","modified_gmt":"2015-11-18T18:19:41","slug":"backbonejs-webpack-lesson-optimization","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/","title":{"rendered":"BackboneJS with Webpack: A lesson in optimization"},"content":{"rendered":"<p>Developing a large BackboneJS\u00a0application presents a unique design problem. As developers, we like to organize our code so it is understandable, logical, and predictable. However, doing so can cause performance issues on the client side.<\/p>\n<p>In this blog I will discuss a handy tool I like to use for this purpose: Webpack. I\u2019ll show it in action, how to use it, and what it is good for. But first, let\u2019s talk about how I came across Webpack.<\/p>\n<h2>An Example<\/h2>\n<p>On a previous project, I was building an audio and video streaming player. The frontend was developed using BackboneJS. I used libraries such as jQuery and SocketIO. Using Require shim configuration, I ended up with my dependencies \/ exports organized as follows.<\/p>\n<pre class=\" brush:perl\">require.config({\r\n    baseUrl: \"js\/\",\r\n    paths: {\r\n        jquery: 'libs\/jquery.js',\r\n        underscore: '\/libs\/underscore.js\/1.6.0\/underscore-min',\r\n        socketio: '\/libs\/socket.io\/0.9.16\/socket.io.min',\r\n        backbone: '\/libs\/backbone.js\/1.1.0\/backbone-min',\r\n        templates: 'templates'\r\n    },\r\n    shim: {\r\n        'jquery': {\r\n            exports: '$'\r\n        },\r\n        'backbone': {\r\n            deps: ['underscore', 'jquery'],\r\n            exports: 'Backbone'\r\n        },\r\n        'underscore': {\r\n            exports: '_'\r\n        },\r\n        'socketio': {\r\n            exports: 'io'\r\n        }\r\n    }\r\n});<\/pre>\n<p>This worked great for my loading all my libraries. For each of my files, I defined the libraries I wanted to use. Breaking down each of my files into modules is a great way to handle organizing the large code base. Then I used\u00a0the <a href=\"https:\/\/github.com\/requirejs\/text\">RequireJS AMD text resource loader<\/a> plugin\u00a0to load all template files.<\/p>\n<pre class=\" brush:perl\">define([\r\n    'jquery',\r\n    'underscore',\r\n    'backbone',\r\n    'text!templates\/recordings\/recordingTemplate.html'\r\n], function($, _, Backbone, recordingTemplate) {\r\n   \/\/ Do some stuff\r\n}<\/pre>\n<p>At the time this was a decent solution. My code base was organized, easy to understand, and predictable. However, the larger my application became, a performance problem began to develop. For each template that was added, a new call to the server was made. This began to balloon the initial loading time of the application.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/keyholesoftware.com\/wp-content\/uploads\/templateLoading.jpg\" alt=\"\" width=\"445\" height=\"274\" \/><\/p>\n<p>Wouldn\u2019t it be great if all necessary resources were compacted into a single file, optimizing the loading time, and still be able to keep our code organized?<\/p>\n<p>Developing a BackboneJS app all in a single file would be frustrating\u00a0experience to manage.\u00a0That\u2019s where Webpack comes to the rescue.<\/p>\n<p><strong>What is Webpack?<\/strong><\/p>\n<p>Webpack is a module bundler that takes your files, compacts them, and generates a static file. Think of it as your own personal secretary\u00a0there to help keep your life organized. You provide the configuration, it supplies the optimization.<\/p>\n<p>Webpack\u2019s primary goal is\u00a0to keep initial loading time down. It does this by <em><a href=\"https:\/\/webpack.github.io\/docs\/code-splitting.html\">code splitting<\/a><\/em>, and <em><a href=\"http:\/\/webpack.github.io\/docs\/using-loaders.html\">loaders<\/a><\/em>.<\/p>\n<p><strong>Code Splitting<\/strong><\/p>\n<p>Code splitting is ideal for\u00a0large applications where it is not efficient to put all code into a single file. Some blocks of code may only be useful for certain pages of the site. Using this opt-in feature allows you to define the split points in your code base, and Webpack will optimize the dependencies required to generate the optimal bundle.<\/p>\n<pre class=\" brush:perl\">var a = require(\"a\");\r\nrequire.ensure([\"b\"], function(require) {\r\n    require(\"a\").dosomething();\r\n    var c = require(\"c\");\r\n});<\/pre>\n<p>This example uses CommonJS <a href=\"https:\/\/webpack.github.io\/docs\/code-splitting.html#require-ensure\">require.ensure<\/a>\u00a0to load resources on demand. The final output would contain two chunked files:<\/p>\n<ul>\n<li>output.js \u2013 the primary entry point chunk containing\n<ul>\n<li>chunk loading logic<\/li>\n<li>module A<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li>1.output.js \u2013 the additional chunk to be loaded on demand containing\n<ul>\n<li>module B<\/li>\n<li>module C<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre class=\" brush:perl\">[sixthpoint@sixthpoint webpack-code-splitting]$ webpack\r\nHash: e863fe1f9db99737fcd2\r\nVersion: webpack 1.12.2\r\nTime: 564ms\r\n      Asset       Size  Chunks             Chunk Names\r\n  output.js     302 kB       0  [emitted]  main\r\n1.output.js  172 bytes       1  [emitted]  \r\n   [0] .\/main.js 338 bytes {0} [built]\r\n   [6] .\/a.js 18 bytes {0} [built]\r\n   [7] .\/b.js 19 bytes {1} [built]\r\n   [8] .\/c.js 17 bytes {1} [built]<\/pre>\n<p><strong>Loaders<\/strong><\/p>\n<p><a href=\"http:\/\/webpack.github.io\/docs\/using-loaders.html\">Loaders preprocess <\/a>files as you use the require() method. Using a loader you can easy require() resources such as CSS, images, or\u00a0compile-to JS languages (<a href=\"http:\/\/coffeescript.org\/\">CoffeeScript<\/a> or <a href=\"https:\/\/facebook.github.io\/react\/index.html\">JSX<\/a>).<\/p>\n<p>By default, Webpack knows how to process your JavaScript files, minify, and combine them. But it doesn\u2019t really know how to do much else. Loaders are the solution to processing different types of files and turn them into usable resources for your application.<\/p>\n<p>Load Bootstrap CSS file:<\/p>\n<pre class=\" brush:perl\">require('.\/styles.css');<\/pre>\n<p>Create a image element, and set the src to the image resource file:<\/p>\n<pre class=\" brush:perl\">var img = document.createElement('img');\r\nimg.src = require('.\/bootstrap-logo.png');<\/pre>\n<p>Using the CLI, all loaders can be defined in the\u00a0<strong>webpack.config.js<\/strong> file.<\/p>\n<pre class=\" brush:perl\">module.exports = {\r\n  entry: '.\/main.js',\r\n  output: {\r\n    filename: 'output.js'       \r\n  },\r\n  module: {\r\n    loaders: [\r\n      { test: \/\\.css$\/, loader: \"style!css\" },\r\n      { test: \/\\.png$\/, loader: \"url-loader?mimetype=image\/png\" }\r\n    ]\r\n  }\r\n};<\/pre>\n<p>This example configuration file sets the application entry point, desired output file name for webpack to build, and a list of\u00a0two loaders (CSS and PNG).<\/p>\n<p>If you want to test this out for yourself, check out this github repo:\u00a0<a href=\"https:\/\/github.com\/sixthpoint\/webpack-async-code-splitting\">https:\/\/github.com\/sixthpoint\/webpack-async-code-splitting<\/a><\/p>\n<p><strong>How do I use BackboneJS\u00a0with Webpack?<\/strong><\/p>\n<p>Above I showed my starter application which had an initial loading performance issue. Remember all those template calls? Webpack async loading and code splitting is going to significantly decrease load times. Let\u2019s assume my application needs only a two entry points:<\/p>\n<ul>\n<li>#\/nowplaying \u2013 will be responsible for\u00a0loading data from socket.io<\/li>\n<li>#\/schedules \u2013 will display all scheduling information<\/li>\n<\/ul>\n<p>To start I have modified my Webpack config file and using the <a href=\"https:\/\/webpack.github.io\/docs\/list-of-plugins.html#provideplugin\">providePlugin <\/a>added jQuery, Backbone, and Underscore to the global scope of my application. I will no longer have to require these libraries through my app. \u00a0This is similar to the shim config above.<\/p>\n<pre class=\" brush:perl\">var webpack = require('webpack');\r\n\r\nmodule.exports = {\r\n  entry: '.\/main.js',\r\n  output: {\r\n    filename: 'output.js'       \r\n  },\r\n  module: {\r\n    loaders: [\r\n      { test: \/\\.css$\/, loader: \"style-loader!css-loader\" },\r\n      { test: \/\\.png$\/, loader: \"url-loader?mimetype=image\/png\" },\r\n    ]\r\n  },\r\n  plugins : [ new webpack.ProvidePlugin({\r\n\t\t\t$ : \"jquery\",\r\n\t\t\tBackbone : \"backbone\",\r\n\t\t\t_ : \"underscore\"\r\n\t\t}) ]\r\n};<\/pre>\n<p>The most important file of this app is the Backbone router. The router defines the code splitting points.<\/p>\n<p>Notice that by using require.ensure, I will load only the socket.io API resource when navigating to the now playing page. This way, if somebody never goes to the now playing page, the resources for that page will never have to be loaded. If the user navigates to the now playing page, it will then be cached for if they return, for performance reasons.<\/p>\n<pre class=\" brush:perl\">var AppRouter = Backbone.Router.extend({\r\n\troutes : {\r\n\t\t'nowplaying' : 'nowplaying',\r\n\t\t'schedule' : 'schedule',\r\n\t\t'*actions' : 'home'\r\n\t}\r\n});\r\n\r\nvar initialize = function() {\r\n\tvar appRouter = new AppRouter;\r\n\r\n\tappRouter.on('route:home', function() {\r\n\t\t$('#content').text(\"Home Screen\");\r\n\t});\r\n\r\n\tappRouter.on('route:nowplaying', function() {\r\n\t\trequire.ensure([], function() {\r\n                    \/\/ nowPlayingView contains socketIO resource\r\n\t\t    require('.\/nowplayingView');\r\n\t\t  });\r\n\t});\r\n\r\n\tappRouter.on('route:schedule', function() {\r\n\t\trequire.ensure([], function() {\r\n\t\t    require('.\/scheduleView');\r\n\t\t  });\r\n\t});\r\n\r\n\tBackbone.history.start();\r\n};\r\n\r\nmodule.exports = initialize;<\/pre>\n<p>So how does Webpack organize this? Simple, both the now playing view (1.output.js) and the schedule view (2.output.js) get their respective files since they are async loaded.<\/p>\n<p>Here is the output of the terminal, as expected:<\/p>\n<pre class=\" brush:perl\">[sixthpoint@sixthpoint webpack-backboneJS-socketIO-client]$ webpack\r\nHash: b29b2a6017bad0dd0577\r\nVersion: webpack 1.12.2\r\nTime: 808ms\r\n      Asset       Size  Chunks             Chunk Names\r\n  output.js     388 kB       0  [emitted]  main\r\n1.output.js     180 kB       1  [emitted]  \r\n2.output.js  248 bytes       2  [emitted]  \r\n   [0] .\/main.js 54 bytes {0} [built]\r\n   [1] .\/router.js 604 bytes {0} [built]\r\n   [5] .\/nowplayingView.js 132 bytes {1} [built]\r\n  [56] .\/scheduleView.js 37 bytes {2} [built]\r\n    + 53 hidden modules<\/pre>\n<h2>Final Thoughts<\/h2>\n<p>What kind of project is Webpack good for? Webpack is great for any scale of project. It is simple to use and configure. Anyone who is developing a JavaScript application should consider using Webpack for its performance improvements and excellent set of plugins.<\/p>\n<p>The complete source code of the optimized project can be found on github:\u00a0<a href=\"https:\/\/github.com\/sixthpoint\/webpack-backbonejs-socketIO-client\">https:\/\/github.com\/sixthpoint\/webpack-backbonejs-socketIO-client<\/a><\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"http:\/\/keyholesoftware.com\/2015\/11\/16\/backbonejs-with-webpack-a-lesson-in-optimization\/\">BackboneJS with Webpack: A lesson in optimization<\/a> from our <a href=\"http:\/\/www.webcodegeeks.com\/wcg\/\">WCG partner<\/a> Keyhole Software at the <a href=\"http:\/\/keyholesoftware.com\/\">Keyhole Software<\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Developing a large BackboneJS\u00a0application presents a unique design problem. As developers, we like to organize our code so it is understandable, logical, and predictable. However, doing so can cause performance issues on the client side. In this blog I will discuss a handy tool I like to use for this purpose: Webpack. I\u2019ll show it &hellip;<\/p>\n","protected":false},"author":22,"featured_media":915,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[],"class_list":["post-8641","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-backbone-js"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>BackboneJS with Webpack: A lesson in optimization - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Developing a large BackboneJS\u00a0application presents a unique design problem. As developers, we like to organize our code so it is understandable, logical,\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"BackboneJS with Webpack: A lesson in optimization - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Developing a large BackboneJS\u00a0application presents a unique design problem. As developers, we like to organize our code so it is understandable, logical,\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:author\" content=\"http:\/\/facebook.com\/keyholesoftware\" \/>\n<meta property=\"article:published_time\" content=\"2015-11-26T10:15:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Keyhole Software\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/keyholesoftware\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Keyhole Software\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/\"},\"author\":{\"name\":\"Keyhole Software\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/10701460d97ebefdaf658a4f4535fff2\"},\"headline\":\"BackboneJS with Webpack: A lesson in optimization\",\"datePublished\":\"2015-11-26T10:15:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/\"},\"wordCount\":925,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg\",\"articleSection\":[\"Backbone.js\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/\",\"name\":\"BackboneJS with Webpack: A lesson in optimization - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg\",\"datePublished\":\"2015-11-26T10:15:59+00:00\",\"description\":\"Developing a large BackboneJS\u00a0application presents a unique design problem. As developers, we like to organize our code so it is understandable, logical,\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Backbone.js\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/backbone-js\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"BackboneJS with Webpack: A lesson in optimization\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/10701460d97ebefdaf658a4f4535fff2\",\"name\":\"Keyhole Software\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/68be341bef51b95ced09befd6a7e0ca930461d95f3a64285e03e7925b8f5de47?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/68be341bef51b95ced09befd6a7e0ca930461d95f3a64285e03e7925b8f5de47?s=96&d=mm&r=g\",\"caption\":\"Keyhole Software\"},\"description\":\"Keyhole is a midwest-based consulting firm with a tight-knit technical team. We work primarily with Java, JavaScript and .NET technologies, specializing in application development. We love the challenge that comes in consulting and blog often regarding some of the technical situations and technologies we face.\",\"sameAs\":[\"http:\/\/keyholesoftware.com\/\",\"http:\/\/facebook.com\/keyholesoftware\",\"http:\/\/linkedin.com\/company\/keyhole-software\",\"https:\/\/x.com\/http:\/\/twitter.com\/keyholesoftware\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/keyhole-software\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"BackboneJS with Webpack: A lesson in optimization - Web Code Geeks - 2026","description":"Developing a large BackboneJS\u00a0application presents a unique design problem. As developers, we like to organize our code so it is understandable, logical,","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/","og_locale":"en_US","og_type":"article","og_title":"BackboneJS with Webpack: A lesson in optimization - Web Code Geeks - 2026","og_description":"Developing a large BackboneJS\u00a0application presents a unique design problem. As developers, we like to organize our code so it is understandable, logical,","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_author":"http:\/\/facebook.com\/keyholesoftware","article_published_time":"2015-11-26T10:15:59+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg","type":"image\/jpeg"}],"author":"Keyhole Software","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/keyholesoftware","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Keyhole Software","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/"},"author":{"name":"Keyhole Software","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/10701460d97ebefdaf658a4f4535fff2"},"headline":"BackboneJS with Webpack: A lesson in optimization","datePublished":"2015-11-26T10:15:59+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/"},"wordCount":925,"commentCount":2,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg","articleSection":["Backbone.js"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/","name":"BackboneJS with Webpack: A lesson in optimization - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg","datePublished":"2015-11-26T10:15:59+00:00","description":"Developing a large BackboneJS\u00a0application presents a unique design problem. As developers, we like to organize our code so it is understandable, logical,","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/backbonejs-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/backbone-js\/backbonejs-webpack-lesson-optimization\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"Backbone.js","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/backbone-js\/"},{"@type":"ListItem","position":4,"name":"BackboneJS with Webpack: A lesson in optimization"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/10701460d97ebefdaf658a4f4535fff2","name":"Keyhole Software","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/68be341bef51b95ced09befd6a7e0ca930461d95f3a64285e03e7925b8f5de47?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/68be341bef51b95ced09befd6a7e0ca930461d95f3a64285e03e7925b8f5de47?s=96&d=mm&r=g","caption":"Keyhole Software"},"description":"Keyhole is a midwest-based consulting firm with a tight-knit technical team. We work primarily with Java, JavaScript and .NET technologies, specializing in application development. We love the challenge that comes in consulting and blog often regarding some of the technical situations and technologies we face.","sameAs":["http:\/\/keyholesoftware.com\/","http:\/\/facebook.com\/keyholesoftware","http:\/\/linkedin.com\/company\/keyhole-software","https:\/\/x.com\/http:\/\/twitter.com\/keyholesoftware"],"url":"https:\/\/www.webcodegeeks.com\/author\/keyhole-software\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/8641","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=8641"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/8641\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/915"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=8641"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=8641"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=8641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}