This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
josh70520
I'm looking for the ability to put something in the scripts placeholder, but only if it's not been put there before.
Case point for a carousel partial that might be used multiple times on a page:
<div class="glider">
...
</div>
{% put scripts %}
{% once %}
<script src="https://cdn.jsdelivr.net/npm/glider-js@1/glider.min.js"></script>
<script>
window.addEventListener('load', function(){
new Glider(document.querySelector('.glider'), {});
});
</script>
{% endonce %}
{% endput %}
daftspunky
There is no feature like this, but the addJs/addCs
functions do eliminate duplicate scripts from being added programmatically. There are no promises but this could work
{% do this.controller.addJs('https://cdn.jsdelivr.net/npm/glider-js@1/glider.min.js') %}
1-3 of 3