forked from hotwired/turbo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript_warning.js
27 lines (22 loc) · 895 Bytes
/
script_warning.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { unindent } from "./util"
;(() => {
let element = document.currentScript
if (!element) return
if (element.hasAttribute("data-turbo-suppress-warning")) return
element = element.parentElement
while (element) {
if (element == document.body) {
return console.warn(
unindent`
You are loading Turbo from a <script> element inside the <body> element. This is probably not what you meant to do!
Load your application’s JavaScript bundle inside the <head> element instead. <script> elements in <body> are evaluated with each page change.
For more information, see: https://turbo.hotwired.dev/handbook/building#working-with-script-elements
——
Suppress this warning by adding a "data-turbo-suppress-warning" attribute to: %s
`,
element.outerHTML
)
}
element = element.parentElement
}
})()