Skip to content

Installing

Greg Bowler edited this page Jun 3, 2025 · 3 revisions

Add Turbo to your package.json

package.json is a file in your project’s root directory that:

  • Describes your project (name, version, etc.)
  • Lists client-side dependencies (like Turbo)
  • Defines scripts (e.g. npm run build)
  • Configures build/test tools

It is used by tools such as npm, yarn, pnpm.

To add Turbo to your package.json dependencies, run npm install github:phpgt/Turbo. You can also install a specific version by adding the version to the command, for example npm install "github:phpgt/Turbo#v1.2.3" will install version 1.2.3.

Include Turbo in your project

Option 1: Importing as an ES module

Whatever build system you use, to start using all of Turbo's functionality, import it into your JavaScript by using the import tag:

import "@phpgt/turbo";

This is typically done in your main script. In WebEngine applications, this is found in the file script/script.es6.

Importing with debug support

If you're contributing to Turbo, it's useful to enable debugging. To do that, import with the following line prepended to the typical import line:

import { TurboDebug } from "@phpgt/turbo";
import "@phpgt/turbo";

Option 2: Importing in HTML

If you don't use a build system, it's possible to import the script directly. You will need to copy a file into a location that is served by your web server. The file is located in node_modules/@phpgt/turbo/dist/turbo.js.

Once the turbo.js file is copied into a public web directory, import Turbo as an ES module by adding the following script in your HTML:

<script type="module" src="/turbo.js" defer></script>

Check your JavaScript console for Turbo enabled

If everything has gone well, you should see the message Turbo enabled in your browser's JavaScript console.

Add data-turbo attributes to start using the library

There is no configuration to start using Turbo. Add data-turbo attributes to the elements you want to enhance, and the library will automatically set everything up for you.

See the next page for a list of turbo attributes.