When needing to make layout or content changes to your website that are not possible using the Website Pages editor, you may be able to use JavaScript to modify content once the page is already displayed.
Prerequisites
- Experience with JavaScript
- Experience with jQuery JavaScript library
- Be familiar with the DecoNetwork Website Pages editor
DecoNetwork embeds the jQuery library on the front-end so if you plan on using it, there may not be a need for you to embed it yourself. Using the included jQuery library instead of embedding your own will reduce the resources downloaded when a user visits your page. DecoNetwork uses the function variable $dnj to make calls to the included jQuery library.
To optimize page loading times, DecoNetwork defers loading of resources (including jQuery library) till the very end of the page in some scenarios. To account for this, you will need to wrap your code with the dnOnLoad function as shown below. This function gets called once all DecoNetwork resources have been downloaded.
<script type="text/javascript"> dnOnLoad(function() { // $dnj('body').prepend("<p>Hello World!</p>"); ... }); </script>
Your script block can be placed into an HTML widget dropped onto a page via the Website Pages editor. Note that widgets placed in the footer are present on every page across the entire site; this can be useful if you have a script that you want to run on every page. (Scripts can also be placed onto your site via the Customize Template HTML area although doing this can result in less flexibility with your site as some options of the Website Page editor will no longer toggle once you've starting using a customized HTML template.)
Comments
0 comments
Please sign in to leave a comment.