Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jmerle committed Jul 7, 2019
1 parent 7af10a0 commit 35dd78f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
9 changes: 5 additions & 4 deletions lib/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,17 @@ def query_string_for_redirection
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
Expand Down
5 changes: 2 additions & 3 deletions views/service-worker.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand Down

0 comments on commit 35dd78f

Please sign in to comment.