Tonejs / Tone.js

A Web Audio framework for making interactive music in the browser.
https://tonejs.github.io
MIT License
13.39k stars 976 forks source link

Custom slim builds #1103

Closed jonaslund closed 2 years ago

jonaslund commented 2 years ago

I'm pressed for performance space, and would like to have the option of building a custom version of Tone.js that only includes a subset of features, let's say, I only need to use the Tone.Synth, no AM/FM Synths etc, and only the Sequencer.

How could I reduce the total kb's of usage from Tone.js by building a custom limited slimmed down version?

Thank you for a super library :)

cephasteom commented 2 years ago

Morning @jonaslund. I'll preface this with a - I might be wrong here. My understanding of a bundler such as Webpack is that it only bundles up the scripts you import. So:

Rather than using the full import of Tone, for example:

import * as Tone from 'tone'

const synth = new Tone.Synth()

You could instead just import the classes that you need:

import { Synth } from 'tone'

const synth = new Synth()

This should reduce the amount of code that you're loading and including in the final bundle of your application.

jonaslund commented 2 years ago

Yes, good point.