Skip to content

Commit 35dd78f

Browse files
committed
Refactoring
1 parent 7af10a0 commit 35dd78f

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ The web app is all client-side JavaScript, written in [CoffeeScript](http://coff
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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,17 @@ def query_string_for_redirection
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('[email protected]'),
201201
image_path('docs-2.png'),
202202
image_path('[email protected]'),
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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ const cachePaths = [
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 %>

0 commit comments

Comments
 (0)