Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New scripts not executed on subsequent loads #46

Closed
arctic-hen7 opened this issue Oct 4, 2021 · 2 comments
Closed

New scripts not executed on subsequent loads #46

arctic-hen7 opened this issue Oct 4, 2021 · 2 comments
Assignees
Labels
A-templates Area: templates C-bug Category: bug C-docs Category: documentation P-high Priority: high wontfix This will not be worked on

Comments

@arctic-hen7
Copy link
Member

Describe the bug
Any <script> tags specified through Perseus via .head() will not be loaded when the page changes. This results in unexpected behaviors like syntax highlighting scripts only working once the page is fully reloaded, and needs to be documented.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
The scripts should run, or this should be documented.

Environment (please complete the following information):

  • Perseus Version: v0.3.0-beta.6
  • Sycamore Version: v0.6.1
  • OS: Ubuntu
  • Browser: Firefox
  • Browser Version: 93

Additional context
This appears to be because Perseus uses .set_inner_html() to set the new <head>, and browsers will only load new scripts if they're added with .append_child() (web-sys functions). This is likely infeasible without considerable rendering changes or additional overhead, so this behavior should be copiously documented so we don't leave users in the dark on this, because it is extremely difficult to debug without knowledge of how Perseus handles subsequent loads.

@arctic-hen7 arctic-hen7 added C-bug Category: bug C-docs Category: documentation wontfix This will not be worked on A-templates Area: templates P-high Priority: high labels Oct 4, 2021
@arctic-hen7 arctic-hen7 self-assigned this Oct 4, 2021
@arctic-hen7
Copy link
Member Author

I'll leave this issue open until documentation for this is live, which I'll leave until the new website is live, which should happen very soon. In the meantime, load your <script>s in the body of the template rather than in .head(). If they absolutely must be in the <head> for some reason, you'll probably have to put them in index.html and make them listen for the onhashchange event and then run only if the URL is for the page that it should run on (that should work, but haven't tested it).

For any normal purposes though, just put the scripts at the top of the template (or at the end if they can run after the page is rendered).

@arctic-hen7
Copy link
Member Author

I also haven't confirmed this behavior on browsers other than Firefox, it's worth noting.

arctic-hen7 added a commit that referenced this issue Oct 4, 2021
arctic-hen7 added a commit that referenced this issue Oct 4, 2021
* feat(website): ✨ added basic website boilerplate

* chore: 🔧 added automatic reloading to site dev scripts

* feat(website): ✨ added tailwindcss

* feat(website): ✨ added initial landing page

* feat(website): ✨ added landing page

* chore(website): 🔧 make browsersync allow non-extensioned files

* feat(website): ✨ added comparisons page and improved mobile support on landing page

* refactor(book): ♻️ refactored book for website deployment

* refactor(book): ♻️ refactored book for i18n

* refactor(book): ♻️ refactored docs for new links systems

* feat(website): ✨ created basic docs system with generation

No styling yet at all, but the pages are all generated.

* feat(website): ✨ added docs stability system

No proper diplaying yet though.

* refactor(book): ♻️ removed `no_run` directives in docs

* refactor(book): ♻️ corrected titles in `SUMMARY.md` files

* feat(website): ✨ created a docs system

* feat(website): ✨ added docs version switcher

* refactor(book): ♻️ made all line includes use new directive `#lines_include`

* feat(website): ✨ added code including

Can't include specific lines yet though.

* feat(website): ✨ added support for  including specific lines

* docs(book): ✏️ fixed 'amlagamation' typo

* fix(website): 🐛 fixed prism load failures

Caused by #46.

* feat(website): ✨ created placeholder for comparisons page

Needs to be more mobile-friendly, that'll come soon.

* chore: 🔧 added `rust-toolchain` for netlify

* chore(website): 📦 added `pkg/` to build temporarily

This might rectify Netlify deployment issues.

* chore(website): 🙈 removed `pkg/`

Abandoning Netlify for this.

* fix(website): 🐛 fixed docs version switcher in dark mode

* fix(website): 🐛 fixed status messages in dark mode

* chore(website): 🔧 added bonnie script to deploy site

* ci(website): 👷 added ci build for website

* ci(website): 💚 fixed ci for tailwindcss

We now use `npx` for the production build.

* refactor(website): 🚨 silenced linter warnings for comparisons page placeholder

Removed `components/comparisons.rs` from the module, but kept the file.

* ci(website): 💚 fixed ci by adding `npm install` stage

* ci(website): 👷 updated ci build for full deployment

* docs: 📝 added warning notice to readme about switch to website
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-templates Area: templates C-bug Category: bug C-docs Category: documentation P-high Priority: high wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant