History

Refactoring

Jasper van Merle committed 7 years ago

Commit 35dd78f1 parent 7af10a03 files · +8 −8Browse files

Unified · Split

3 files
  1. README.md +1 −1
  2. lib/app.rb +5 −4
  3. views/service-worker.js.erb +2 −3
README.md+1−1
@@ -59,7 +59,7 @@ The web app is all client-side JavaScript, written in [CoffeeScript](http://coff · 58 unmodified lines
5959
6060 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.
6161
62−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.
62+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.
6363
6464 DevDocs being a developer tool, the browser requirements are high:
6565
lib/app.rb+5−4
@@ -192,16 +192,17 @@ class App < Sinatra::Application · 191 unmodified lines
192192 request.query_string.empty? ? nil : "?#{request.query_string}"
193193 end
194194
195− def manifest_asset_urls
196− @@manifest_asset_urls ||= [
195+ def service_worker_asset_urls
196+ @@service_worker_asset_urls ||= [
197197 javascript_path('application', asset_host: false),
198198 stylesheet_path('application'),
199199 image_path('docs-1.png'),
200200 image_path('docs-1@2x.png'),
201201 image_path('docs-2.png'),
202202 image_path('docs-2@2x.png'),
203− asset_path('docs.js')
204− ]
203+ asset_path('docs.js'),
204+ App.production? ? nil : javascript_path('debug'),
205+ ].compact
205206 end
206207
207208 def app_size
views/service-worker.js.erb+2−3
@@ -13,9 +13,8 @@ const cachePaths = [ · 12 unmodified lines
1313 '/images/webapp-icon-128.png',
1414 '/images/webapp-icon-256.png',
1515 '/images/webapp-icon-512.png',
16− '<%= manifest_asset_urls.join "',\n '" %>',
17− '<%= doc_index_urls.join "',\n '" %>',<% unless App.production? %>
18− '<%= javascript_path('debug') %>',<% end %>
16+ '<%= service_worker_asset_urls.join "',\n '" %>',
17+ '<%= doc_index_urls.join "',\n '" %>',
1918 ];
2019
2120 <%# Set-up the cache %>