diff --git a/_source/handbook/08_installing.md b/_source/handbook/08_installing.md index 21b5a02..a86d5e6 100644 --- a/_source/handbook/08_installing.md +++ b/_source/handbook/08_installing.md @@ -13,12 +13,20 @@ You can float on the latest release of Turbo using a CDN bundler like Skypack. S ## As An npm Package -You can install Turbo from npm via the `npm` or `yarn` packaging tools. Then require or import that in your code: +You can install Turbo from npm via the `npm` or `yarn` packaging tools. + +If you using any Turbo functions such as `Turbo.visit()` import the `Turbo` functions into your code: ```javascript import * as Turbo from "@hotwired/turbo" ``` +If you're *not* using any Turbo functions such as `Turbo.visit()` import the library. This avoids issues with tree-shaking and unused variables in some bundlers. See [Import a module for its side effects only](https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/import#import_a_module_for_its_side_effects_only) on MDN. + +```javascript +import "@hotwired/turbo"; +``` + ## In a Ruby on Rails application The Turbo JavaScript framework is included with [the turbo-rails gem](https://github.com/hotwired/turbo-rails) for direct use with the asset pipeline.