?
avatar maofree
maofree
30 Jan 2015

Hi
I've seen that if to load a page it is necessary to call more than one addSCriptDeclaration methods
inside the source page there are some javascript duplications of the javascript code present into these addSCriptDeclaration (from below you can see this problem. The page should load only the second part).
In my website I use one addSCriptDeclaration in the index.php of the theme and one addSCriptDeclaration in the default.php of my module.
So if a page load that module I get this duplication instead if that module is not loaded this problem is not present. I've not tried with 2-3 modules that use addSCriptDeclaration method.
This problem is present only using progressive cache instead with conservative cache and no cache all is ok.
Thi issue is on a 3.3.6

  <script type="text/javascript">
jQuery(window).on('load',  function() {
                new JCaption('img.caption');
            });
    jQuery(document).ready(function(){
        jQuery('#main-menu, #bottommenu ul').removeClass('nav');
        jQuery('#main-menu').smartmenus({
            subMenusMaxWidth: '27em'
        });

        jQuery('#main-menu').mobileMenu({defaultText: 'Accedi a ...;'});
        jQuery('.select-menu').removeClass('menu sm sm-clean');

        jQuery().UItoTop({
            min: 500,
            inDelay: 600,
            outDelay: 400,
            scrollSpeed: 300,
            easingType: 'jswing',
            text: 'Scorri verso l\'alto'
        });

        jQuery('.image-gallery').fancybox({
            autoPlay: true,
            openEffect: 'elastic',
            closeEffect: 'elastic'
        });
    });

jQuery(window).on('load',  function() {
                new JCaption('img.caption');
            });
    jQuery(document).ready(function(){
        jQuery('#main-menu, #bottommenu ul').removeClass('nav');
        jQuery('#main-menu').smartmenus({
            subMenusMaxWidth: '27em'
        });

        jQuery('#main-menu').mobileMenu({defaultText: 'Accedi a ...;'});
        jQuery('.select-menu').removeClass('menu sm sm-clean');

        jQuery().UItoTop({
            min: 500,
            inDelay: 600,
            outDelay: 400,
            scrollSpeed: 300,
            easingType: 'jswing',
            text: 'Scorri verso l\'alto'
        });

        jQuery('.image-gallery').fancybox({
            autoPlay: true,
            openEffect: 'elastic',
            closeEffect: 'elastic'
        });
    });

    jQuery(document).ready(function(){
        jQuery('#maocarousel').slick({
            pauseOnHover: true,
            slidesToShow: 1,
            slidesToScroll: 1,
            autoplay: true,
            autoplaySpeed: 8000,
            dots: false,
            arrows: true,
            infinite: true,
            swipe: true,
            touchMove: true,
            lazyLoad: 'ondemand',
            speed: 1500
        });
    });

  </script>

If you want I can show this problem on the website (now the cache is disabled)

thanks
bye

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
3.00

avatar maofree maofree - open - 30 Jan 2015
avatar jissues-bot jissues-bot - change - 30 Jan 2015
Labels Added: ?
avatar brianteeman
brianteeman - comment - 30 Jan 2015

Iirc conservative cache doesnt cache modules

avatar maofree
maofree - comment - 30 Jan 2015

this issue is with progressive cache

avatar zero-24 zero-24 - change - 30 Jan 2015
Category Cache
avatar zero-24 zero-24 - change - 30 Jan 2015
The description was changed
avatar JoomliC
JoomliC - comment - 2 Feb 2015

Progressive cache should be used only on static website, and of course, could give issue with xhtml content in modules.
As @brianteeman said, the conservative cache should be used in this case ;-)

Don't see it as an issue or bug, but it's true that description for joomla cache config is not really clear...


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5933.
avatar maofree
maofree - comment - 2 Feb 2015

Hi JoomliC
I'm not sure about that, because all methods work well with progressive solution and the loading page is much better than the other options. Only addSCriptDeclaration method has a problem and I think it is just a php issue, it should be nice to take only the last repetition, because it has all the right javascript code.
About static website, I don't think that it is true, because joomla is a dynamic cms written i php and it is modular

bye

avatar brianteeman
brianteeman - comment - 2 Feb 2015

By static web site Joomlic means a web site that doesnt change and doesnt
have modules that are created dynamically from the content of the site

On 2 February 2015 at 20:51, maofree notifications@github.com wrote:

Hi JoomliC
I'm not sure about that, because all methods work well with progressive
solution and the loading page is much better than the other options. Only
addSCriptDeclaration method has a problem and I think it is just a php
issue, it should be nice to take only the last repetition, because it has
all the right javascript code.
About static website, I don't think that it is true, because joomla is a
dynamic cms written i php and it is modular

bye


Reply to this email directly or view it on GitHub
#5933 (comment).

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/

avatar maofree
maofree - comment - 2 Feb 2015

ok

avatar JoomliC
JoomliC - comment - 3 Feb 2015

Yes, this is what i mean by "static".
About your script, why you add it in your module, as it is in the index.php ? It's not needed to add this code in the module, as the index.php will already add it to the header inline...
When you have a script code you don't want it dupplicated, the best way, i think, is to use JHtml::script
;-)

avatar maofree
maofree - comment - 3 Feb 2015

Hi JoomliC
Into the index.php I put only the essential files and code, the remaining is loaded into the pages where this code is required.
https://docs.joomla.org/J3.x:Adding_JavaScript_and_CSS_to_the_page
I think the best solution is to put this js code into a file and load it with addScript or JHtml::script

thanks
bye

avatar maofree
maofree - comment - 3 Feb 2015

moving that code from addSCriptDeclaration to a file loading it with addScript
all problems are solved and I can use progressive cache. Now the loading page is much better.
However I think that addSCriptDeclaration method should be improved to avoid this problem, because addCustomTag works well too.

bye

avatar compojoom
compojoom - comment - 12 Feb 2015

I've been suffering from the same issue for the past couple of years. And I've ended up always using files. Which is pretty stupid when you have just one line to init all the other classes...

The same thing has been reported on the forum few years ago: http://forum.joomla.org/viewtopic.php?f=615&t=719887

Are we going to treat this as a bug? Or are we going to say that you are always supposed to use files instead of addScriptDeclaration?

avatar brianteeman
brianteeman - comment - 8 May 2016

Hi you created this issue sometime ago but have not provided any code for people to evaluate. As no one else has shown any interest in providing the code and you have not then I am closing this issue at this time. If code is provided (a pull request) it can always be re-examined.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5933.

avatar brianteeman brianteeman - change - 8 May 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-05-08 15:39:18
Closed_By brianteeman
avatar brianteeman brianteeman - close - 8 May 2016
avatar brianteeman brianteeman - close - 8 May 2016
avatar bxbroze
bxbroze - comment - 11 Jun 2016

Hi everyone,

Thanks for the tips above, it helped me out :)
I hit that issue on my site. It took me quite a long time to figure out what was going on. For now I set my site to conservative caching instead of progressive caching to workaround the issue.

I don't know what to change to solve this issue so I can't propose a fix. Shouldn't the issue remain open? I don't understand the rationale of closing it because nobody proposed a fix yet.

Thanks & br,
BX


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5933.

Add a Comment

Login with GitHub to post a comment