-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Breaking: Remove custom JS and CSS lazy loading and instead recommend…
… template data-island for everything!
- Loading branch information
Showing
8 changed files
with
126 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,6 +107,20 @@ Place any post-JS content inside of one or more `<template data-island>` element | |
</is-land> | ||
``` | ||
|
||
#### Run your own custom JavaScript | ||
|
||
Embed a script inside the template to run custom JS when the island’s loading conditions have been satisfied! | ||
|
||
```html | ||
<is-land on:visible> | ||
<template data-island> | ||
<script type="module"> | ||
console.log("Hydrating!"); | ||
</script> | ||
</template> | ||
</is-land> | ||
``` | ||
|
||
#### Styling | ||
|
||
The `ready` attribute is added to the `<is-land>` when the island has been hydrated. | ||
|
@@ -119,18 +133,6 @@ is-land[ready] { | |
</style> | ||
``` | ||
|
||
#### Run your own custom JavaScript | ||
|
||
This code runs when the island’s loading conditions have been satisfied! Note the `type="module/island"`. | ||
|
||
```html | ||
<is-land on:visible> | ||
<script type="module/island"> | ||
console.log("Hydrating!"); | ||
</script> | ||
</is-land> | ||
``` | ||
|
||
### Framework Support | ||
|
||
[Demos and source in the HTML](https://is-land.11ty.dev/) are available for each framework listed here. | ||
|
@@ -175,13 +177,15 @@ Use the `autoinit` and `import` attributes together to import a third party libr | |
Hello from <span v-html="name">pre-JS</span> | ||
</div> | ||
|
||
<script type="module/island"> | ||
<template data-island> | ||
<script type="module"> | ||
import { createApp } from "https://unpkg.com/[email protected]/dist/vue.esm-browser.prod.js"; | ||
createApp({ | ||
data: () => ({ name: "post-JS" }) | ||
}).mount("#vue-app") | ||
</script> | ||
</script> | ||
</template> | ||
</is-land> | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,14 +31,15 @@ <h3>Client-rendered petite-vue</h3> | |
</template> | ||
</div> | ||
|
||
<!-- when using eagerly loaded islands (no loading conditions), use `type="module"` instead of `type="module/island"` so the preload scanner can find it--> | ||
<script type="module/island"> | ||
import { createApp } from "https://unpkg.com/[email protected]/dist/petite-vue.es.js"; | ||
<template data-island> | ||
<script type="module"> | ||
import { createApp } from "https://unpkg.com/[email protected]/dist/petite-vue.es.js"; | ||
|
||
createApp({ | ||
count: 0, | ||
}).mount("#petite-vue-app") | ||
</script> | ||
createApp({ | ||
count: 0, | ||
}).mount("#petite-vue-app") | ||
</script> | ||
</template> | ||
</is-land> | ||
|
||
<h3>Client-rendered Vue.js</h3> | ||
|
@@ -56,13 +57,15 @@ <h3>Client-rendered Vue.js</h3> | |
</template> | ||
</div> | ||
|
||
<script type="module/island"> | ||
<template data-island> | ||
<script type="module"> | ||
import { createApp } from "https://unpkg.com/[email protected]/dist/vue.esm-browser.prod.js"; | ||
|
||
createApp({ | ||
data: () => ({ count: 0 }) | ||
}).mount("#vue-app") | ||
</script> | ||
</script> | ||
</template> | ||
</is-land> | ||
|
||
<h3>Works with <details></h3> | ||
|
@@ -231,10 +234,12 @@ <h3>With Hydration</h3> | |
{% assign component = "./lib/vue/vue-component.js" | vue %} | ||
<div id="vue-app-ssr">{{ component.html }}</div> | ||
|
||
<script type="module/island"> | ||
import { createSSRApp } from "https://unpkg.com/[email protected]/dist/vue.esm-browser.prod.js"; | ||
import app from "{{ component.clientJsUrl }}"; | ||
<template data-island> | ||
<script type="module"> | ||
import { createSSRApp } from "https://unpkg.com/[email protected]/dist/vue.esm-browser.prod.js"; | ||
import app from "{{ component.clientJsUrl }}"; | ||
|
||
createSSRApp(app).mount("#vue-app-ssr"); | ||
</script> | ||
createSSRApp(app).mount("#vue-app-ssr"); | ||
</script> | ||
</template> | ||
</is-land> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.