Cms is simple how to include javascript in my template

Hi, I'm a little stuck here, I can't seem to include the javascript file in my cmsms template.

<script src="js/slides.min.jquery.js"></script> <script> $(function(){ $('#slides').slides({ preload: true, preloadImage: 'img/loading.gif', play: 5000, pause: 2500, hoverPause: true }); }); </script> 

This code works, it does not include js / slides.min.jquery.js and does not run the script, can someone explain how javascript is included in cmsms templates ...

+6
source share
1 answer

You need to include javascript tags in {literal} tags to avoid compromises trying to parse it. This is an example (from one of my sites) that includes javascript Google analytics.

 {literal} <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXXX-X']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> {/literal} 
+13
source

Source: https://habr.com/ru/post/885970/


All Articles