diff --git a/README.md b/README.md index d8d92143..5114e7e8 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ The web app is all client-side JavaScript, written in [CoffeeScript](http://coff Many of the code's design decisions were driven by the fact that the app uses XHR to load content directly into the main frame. This includes stripping the original documents of most of their HTML markup (e.g. scripts and stylesheets) to avoid polluting the main frame, and prefixing all CSS class names with an underscore to prevent conflicts. -Another driving factor is performance and the fact that everything happens in the browser. `applicationCache` (which comes with its own set of constraints) and `localStorage` are used to speed up the boot time, while memory consumption is kept in check by allowing the user to pick his/her own set of documentations. The search algorithm is kept simple because it needs to be fast even searching through 100,000 strings. +Another driving factor is performance and the fact that everything happens in the browser. A service worker (which comes with its own set of constraints) and `localStorage` are used to speed up the boot time, while memory consumption is kept in check by allowing the user to pick his/her own set of documentations. The search algorithm is kept simple because it needs to be fast even searching through 100,000 strings. DevDocs being a developer tool, the browser requirements are high: diff --git a/lib/app.rb b/lib/app.rb index d6d30326..4e2b749c 100644 --- a/lib/app.rb +++ b/lib/app.rb @@ -192,16 +192,17 @@ class App < Sinatra::Application request.query_string.empty? ? nil : "?#{request.query_string}" end - def manifest_asset_urls - @@manifest_asset_urls ||= [ + def service_worker_asset_urls + @@service_worker_asset_urls ||= [ javascript_path('application', asset_host: false), stylesheet_path('application'), image_path('docs-1.png'), image_path('docs-1@2x.png'), image_path('docs-2.png'), image_path('docs-2@2x.png'), - asset_path('docs.js') - ] + asset_path('docs.js'), + App.production? ? nil : javascript_path('debug'), + ].compact end def app_size diff --git a/views/service-worker.js.erb b/views/service-worker.js.erb index e2986ede..c962564b 100644 --- a/views/service-worker.js.erb +++ b/views/service-worker.js.erb @@ -13,9 +13,8 @@ const cachePaths = [ '/images/webapp-icon-128.png', '/images/webapp-icon-256.png', '/images/webapp-icon-512.png', - '<%= manifest_asset_urls.join "',\n '" %>', - '<%= doc_index_urls.join "',\n '" %>',<% unless App.production? %> - '<%= javascript_path('debug') %>',<% end %> + '<%= service_worker_asset_urls.join "',\n '" %>', + '<%= doc_index_urls.join "',\n '" %>', ]; <%# Set-up the cache %>