We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36447
    • 98 Posts
    Thanks, @goldsky, that worked perfectly!
      • 18913
      • 654 Posts
      I have been using the "smoothgallery" slideshow on a site and a client commented about load time. Long story short : I changed the MODX api call that injects script and html into the <head> tag and changed it to inject it at the end. I.e. regClientStartupScript becomes regClientScript in the relevant part of smoothgallery.php

      Not only does it still seem to all work (still testing), but the load times (as indicated by tests at www.webpagetest.org) show the *start* of the page rendering happening sooner. So everything appears to be loading faster.

      Hope others can confirm this and that this helps.
      MattC
        • 11055 ☆ A M B ☆
        • 3,112 Posts
        Why did you think at the first place that regClientStartupScript/regClientScript would cause this?
        From Firebug?
          Rico
          Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
          MODx is great, but knowing how to use it well makes it perfect!

          www.virtudraft.com

          Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

          Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

          Maintainter/contributor of Babel

          Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
          • 18913
          • 654 Posts
          If you point that web page test site to a url, it will show you what is getting loaded when, how long it takes, etc.
          I noticed that there was a lot of javascript getting loaded early on, along with CSS. Then, a logo would get loaded, etc.

          So it occurred to me that if I could just bump up the order in which some static elements like the logo were getting loaded, the page would begin to render more quickly.

          One of the data points in the analytics is how long it takes to start rendering the page. Sure enough, the time started to drop down.

          Does that help, or have I missed something obvious?
          Matt
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            No, you aren’t missing anything. That’s a known issue with javascript. A page will display faster if the javascript is at the end of the HTML rather than in the head.

            http://www.stevesouders.com/blog/2009/05/06/positioning-inline-scripts/
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 18913
              • 654 Posts
              I think I have found where I was losing a lot of time on page creation. In the gallery that I was using &ss_img_src was set to "generated". This loop was taking 4+ seconds to execute. I would have thought (I really don’t know why) that once these images were created they would have been available in the MODX cache and not regenerated. But it seems that they get calculated every time and that’s what can make gallery loading slow.

              Perhaps I’ve got some MODX or E2G configuration set incorrectly and that’s why this caching isn’t taking place?

              In any case, when I set that parameter to "original", I pick up a lot of time.

              If anyone can point out what I might be doing incorrectly, I’d be appreciative!
              Matt
                • 11055 ☆ A M B ☆
                • 3,112 Posts
                what is your snippet call, matt?
                  Rico
                  Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
                  MODx is great, but knowing how to use it well makes it perfect!

                  www.virtudraft.com

                  Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

                  Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

                  Maintainter/contributor of Babel

                  Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
                  • 18913
                  • 654 Posts
                  @goldsky : this is the snippet call
                  [!easy2? &slideshow=`smoothgallery` &ss_config=`zoom` &ss_indexfile=`assets/libs/slideshows/smoothgallery/new_smoothgallery.php`   &w=`75` &h=`75` &ss_w=`480` &ss_h=`290` &ss_limit=`none` &gid=`6`!]
                  


                  where "new_smoothgallery.php" is the same as the original, with the exception of the "zoom" config block, which looks like this :
                  if ($ssParams['ss_config'] == 'zoom') {
                  //    $modx->regClientStartupScript(MODX_BASE_URL . 'assets/libs/slideshows/smoothgallery/scripts/mootools-1.2.1-core-yc.js');
                  //    $modx->regClientStartupScript(MODX_BASE_URL . 'assets/libs/slideshows/smoothgallery/scripts/mootools-1.2-more.js');
                  //    $modx->regClientStartupScript(MODX_BASE_URL . 'assets/libs/slideshows/smoothgallery/scripts/ReMooz.js');
                  //    $modx->regClientStartupScript(MODX_BASE_URL . 'assets/libs/slideshows/smoothgallery/scripts/jd.gallery.js');
                  //    $modx->regClientStartupScript(MODX_BASE_URL . 'assets/libs/slideshows/smoothgallery/scripts/jd.gallery.transitions.js');	
                  //    $modx->regClientStartupHTMLBlock('
                  
                      $modx->regClientScript(MODX_BASE_URL . 'assets/libs/slideshows/smoothgallery/scripts/mootools-1.2.1-core-yc.js');
                      $modx->regClientScript(MODX_BASE_URL . 'assets/libs/slideshows/smoothgallery/scripts/mootools-1.2-more.js');
                      $modx->regClientScript(MODX_BASE_URL . 'assets/libs/slideshows/smoothgallery/scripts/ReMooz.js');
                      $modx->regClientScript(MODX_BASE_URL . 'assets/libs/slideshows/smoothgallery/scripts/jd.gallery.js');
                      $modx->regClientScript(MODX_BASE_URL . 'assets/libs/slideshows/smoothgallery/scripts/jd.gallery.transitions.js');	
                      $modx->regClientHTMLBlock('
                          <script type="text/javascript">
                  			function startGallery() {
                  				var myGallery = new gallery($(\'myGallery\'), {
                  					timed: false,
                  					useReMooz: true,
                  					defaultTransition: "fadeslideleft",
                  					embedLinks: false
                  				});
                  			}
                  			window.addEvent(\'domready\',startGallery);
                          </script>
                          ');
                  }
                  


                  I realize that the above mod to the gallery accomodates a sliding transition. But when I put in a bunch of "echo microtime(true)" calls, I found that most of the time was being consumed at the top of this file, in this call
                  $ssFiles = $this->_getSlideShowFiles();
                  


                  Drilling down into that further, I found that it was the ss_img_src=generated condition that was accounting for a lot of the time. When I either explicitly set the parameter to "original" or change the default setting in the module settings, things seemed to improve.

                  BTW, the galleries are about 8-12 images and each is maybe 70+kb in size.

                  Matt
                    • 11055 ☆ A M B ☆
                    • 3,112 Posts
                    hmm....
                    what if you disable the watermark, but keep selecting the generated option?
                      Rico
                      Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
                      MODx is great, but knowing how to use it well makes it perfect!

                      www.virtudraft.com

                      Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

                      Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

                      Maintainter/contributor of Babel

                      Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
                      • 11055 ☆ A M B ☆
                      • 3,112 Posts
                      Congratulation, you just found a bug! tongue
                      Here is the commit.

                      The problem was the false bracket.

                      The extra package has been replaced.
                        Rico
                        Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
                        MODx is great, but knowing how to use it well makes it perfect!

                        www.virtudraft.com

                        Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

                        Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

                        Maintainter/contributor of Babel

                        Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.