Commit 30524901 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'cs-unnecessary-assets' into 'master'

Load d3 only when necessary

Now d3 is only loaded on the users' show page and the graphs pages, where it's necessary.

Redo of !3993.

This decreases page size from 4.6MB to 4.3MB for a given Activity page (before compression), or a savings of 300KB. This is essentially a proof of concept for removing larger dependencies such as the Ace Editor, Chart.js, and Raphael, which will likely provide another 1MB of savings on most pages (again, before compression).

See merge request !4394
parents 34861c5f 586d1a9b
......@@ -18,7 +18,6 @@
#= require jquery.atwho
#= require jquery.scrollTo
#= require jquery.turbolinks
#= require d3
#= require turbolinks
#= require autosave
#= require bootstrap/affix
......@@ -51,7 +50,13 @@
#= require shortcuts_network
#= require jquery.nicescroll
#= require date.format
#= require_tree .
#= require_directory ./behaviors
#= require_directory ./blob
#= require_directory ./ci
#= require_directory ./commit
#= require_directory ./extensions
#= require_directory ./lib
#= require_directory .
#= require fuzzaldrin-plus
#= require cropper
......
# This is a manifest file that'll be compiled into including all the files listed below.
# Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
# be included in the compiled file accessible from http://example.com/assets/application.js
# It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
# the compiled file.
#
#= require_tree .
#= require d3
#= require stat_graph_contributors_util
class @ContributorsStatGraph
init: (log) ->
......
# This is a manifest file that'll be compiled into including all the files listed below.
# Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
# be included in the compiled file accessible from http://example.com/assets/application.js
# It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
# the compiled file.
#
#= require d3
#= require_tree .
module JavascriptHelper
def page_specific_javascripts(js = nil)
@page_specific_javascripts = js unless js.nil?
@page_specific_javascripts
end
end
......@@ -30,6 +30,9 @@
= javascript_include_tag "application"
- if page_specific_javascripts
= javascript_include_tag page_specific_javascripts, {"data-turbolinks-track" => true}
= csrf_meta_tags
= include_gon
......
- page_specific_javascripts asset_path("graphs/application.js")
%ul.nav-links
= nav_link(action: :show) do
= link_to 'Contributors', namespace_project_graph_path
......
- page_title @user.name
- page_description @user.bio
- page_specific_javascripts asset_path("users/application.js")
- header_title @user.name, user_path(@user)
- @no_container = true
......
......@@ -81,6 +81,8 @@ module Gitlab
config.assets.precompile << "print.css"
config.assets.precompile << "notify.css"
config.assets.precompile << "mailers/*.css"
config.assets.precompile << "graphs/application.js"
config.assets.precompile << "users/application.js"
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
......
//= require stat_graph_contributors_graph
//= require graphs/stat_graph_contributors_graph
describe("ContributorsGraph", function () {
describe("#set_x_domain", function () {
......
//= require stat_graph_contributors_util
//= require graphs/stat_graph_contributors_util
describe("ContributorsStatGraphUtil", function () {
......
//= require stat_graph
//= require graphs/stat_graph
describe("StatGraph", function () {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment