Different scripts for different pages? #46
-
A similar question MoOx/pjax#230 I want to have different For example, I have <script src="pjax.js"></script>
<script src="theme.js"></script> on page 1, and And I have <script src="lightgallery.js"></script>
<script src="pjax.js"></script>
<script src="theme.js"></script> on page 2, which I want to call |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The easiest solution would be wrapping the parts that differ among pages into an element that you will add to the <!-- page 1 -->
<div class="differ-among-pages"></div>
<script src="pjax.js"></script>
<script src="theme.js"></script>
<!-- page 2 -->
<div class="differ-among-pages">
<script src="lightgallery.js"></script>
</div>
<script src="pjax.js"></script>
<script src="theme.js"></script> don't forget to select that element like: const pjax = new Pjax({
selectors: [
'.differ-among-pages',
],
}); #31 (comment) shows two other possible solutions. |
Beta Was this translation helpful? Give feedback.
The easiest solution would be wrapping the parts that differ among pages into an element that you will add to the
selectors
option. Make sure to have the wrapper existing on each page. In your example, that could bedon't forget to select that element like:
#31 (comment) shows two other possible solutions.