Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minimize or load intro graph on demand #1336

Closed
jfirebaugh opened this issue Apr 20, 2013 · 3 comments
Closed

minimize or load intro graph on demand #1336

jfirebaugh opened this issue Apr 20, 2013 · 3 comments
Assignees
Labels
performance Optimizing for speed and efficiency

Comments

@jfirebaugh
Copy link
Member

The intro graph is 1.4 MB, ~25% of iD.js, ~50% of iD.min.js, ~20% of retained memory on a fresh page load.

It should either be compressed somehow, or loaded only on demand and unloaded when finished.

@ghost ghost assigned aaronlidman Nov 29, 2013
@bhousel
Copy link
Member

bhousel commented Dec 21, 2015

For now I shrunk it to 527k. It can shrink a lot more - much of the graph is river geometries that extend well beyond where the tutorial is.

var fs = require('fs'),
    _ = require('../js/lib/lodash.js');

var graph = JSON.parse(fs.readFileSync('./introGraph_orig.json', 'utf8'));
_.each(graph, function(v,k) {
    var tags = _.omit(v.tags, function(v,k) {
        if (k.indexOf('tiger:') !== -1) return true;
        if (k.indexOf('addr:') !== -1) return true;
        if (k.indexOf('gnis:') !== -1) return true;
        if (k.indexOf('is_in') !== -1) return true;
        if (['ele','source','wikipedia','website','created_by'].indexOf(k) !== -1) return true;
        return false;
    });
    graph[k] = _.omit(v, ['version','changeset','user','uid','visible','timestamp']);
    if (_.isEmpty(tags)) {
        delete graph[k].tags;
    } else {
        graph[k].tags = tags;
    }
});

fs.writeFileSync('introGraph.js', "iD.introGraph = '" + JSON.stringify(graph) + "';");

@bhousel
Copy link
Member

bhousel commented Dec 21, 2015

For comparison, imagery.json is now at 995K

@bhousel
Copy link
Member

bhousel commented Dec 22, 2015

Updated again, imagery.json now at 274K. We were unnecessarily pretty printing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Optimizing for speed and efficiency
Projects
None yet
Development

No branches or pull requests

3 participants