I'm using plotly.js with Rails 4. For now I just have the lib file /vendor/assets/javascripts/plotly.js and require it in application.js (//= require plotly). Ploly.js is about 1 mb so I want to decrease the size. On the github page there is an instruction how to do this:
// in custom-plotly.js var plotlyCore = require('plotly.js/lib/core'); // Load in the trace types for pie, and choropleth plotlyCore.register([ require('plotly.js/lib/pie'), require('plotly.js/lib/choropleth') ]); module.exports = plotlyCore; // Then elsewhere in your code: var Plotly = require('./path/to/custom-plotly'); I can't figure out where should I put this code to serve just some modules of the lib but not the whole lib.
If it's not possible with built-in features how would you recommend to solve the problem?
1 Answers
Answers 1
This is an instruction for npm modules and Modularizing monolithic JS projects. You don't have a nodejs interpreter in the Rails.
Rails can reduce the size of this js file, by minify.
0 comments:
Post a Comment