Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Hlaing_Min_Than's avatar

Prismjs not working well with Spa route change

i've a vue inertia app which is using prismjs for code syntax highlighting. but i got a problem with prismjs. the codes are not highlighting on page change. It's showing as below. any idea ? pls discuss with me. alt text

0 likes
1 reply
rodrigo.pedra's avatar

On prism.js official site there is a section called "Third-party tutorials"

https://prismjs.com/#tutorials

There you can there are some linked articles on how to use prism.js with ajax returns, angular or react:

The idea is that stock configuration is only called on page load, which on a SPA only happens once on the first load, and not with internal navigation.

So you need to somehow hook at route changes (you didn't share which SPA architecture you are using, nor I am an expert on all front-end technologies), and re-run prism.js to account for new content injected into the DOM.

Good luck!

Please or to participate in this conversation.