-
Notifications
You must be signed in to change notification settings - Fork 0
Installing
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.
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
.
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";
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>
If everything has gone well, you should see the message Turbo enabled
in your browser's JavaScript console.
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.