#Possibility to prerender when using client page libraries?

4 messages · Page 1 of 1 (latest)

crystal carbon
#

Is it possible to prerender a page when using a <script> tag with some client side js library? I'm trying to create a calendar app, using this - https://github.com/year-calendar/js-year-calendar/. It uses vanilla JS to hook onto some element and create a calendar. Is it possible to prerender that? Currently the index.astro file looks like this (omitted some parts for brevity):

<body>
  <div class="calendar"></div>
</body>

<script>
  import Calendar from "js-year-calendar";
  new Calendar(".calendar");
</script>
GitHub

A fully customizable year calendar widget. Contribute to year-calendar/js-year-calendar development by creating an account on GitHub.

stone remnant
#

Yup definitely possible

#

Do you have an issue when prerendering?

crystal carbon
#

Not really an issue, just don't know how to do it 😅
Expected outcome would be that in the /dist bundle there would be only generated html so a div with 12 child divs and so on. Right now it just bundles the script into the final bundle and calendar generation still happens client side