From c7d367996a09032b53f03e44809a769cb566808e Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 16 Apr 2015 15:40:23 -0400 Subject: [PATCH] PERF: Concatenate scripts in development mode This improves my DOMContentLoaded from 9s+ to less than 4s. Pinging @SamSaffron on this because this was previously controversial. This implementation adds the `@sourceURL` directive so chrome correctly identifies the source files. --- config/environments/development.rb | 2 +- lib/discourse_iife.rb | 1 + .../tilt/es6_module_transpiler_template.rb | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index 160ee7dc6..6edea4c1f 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -22,7 +22,7 @@ Discourse::Application.configure do # Don't Digest assets, makes debugging uglier config.assets.digest = false - config.assets.debug = true + config.assets.debug = false # Raise an error on page load if there are pending migrations config.active_record.migration_error = :page_load diff --git a/lib/discourse_iife.rb b/lib/discourse_iife.rb index fa80aa43f..80033a11b 100644 --- a/lib/discourse_iife.rb +++ b/lib/discourse_iife.rb @@ -32,6 +32,7 @@ class DiscourseIIFE < Sprockets::Processor .sub("/app/assets/javascripts", "") .sub("/test/javascripts", "") res << "\nwindow.__jshintSrc = window.__jshintSrc || {}; window.__jshintSrc['/assets#{req_path}'] = #{data.to_json};\n" + res << "\n//@ sourceURL=/#{context.logical_path}\n" end res diff --git a/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb b/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb index 277760358..d404d42fc 100644 --- a/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb +++ b/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb @@ -127,6 +127,7 @@ module Tilt req_path = "/assets/#{scope.logical_path}.#{extension}" @output << "\nwindow.__jshintSrc = window.__jshintSrc || {}; window.__jshintSrc['#{req_path}'] = #{data.to_json};\n" + @output << "\n//@ sourceURL=/#{scope.logical_path}\n" end @output