Jump to content

MatthewCraig

Circle Member
  • Posts

    8
  • Joined

  • Last visited

Reputation Activity

  1. Like
    MatthewCraig got a reaction from Beyondspace in Can I force a custom script to load after other elements?   
    Site URL: https://www.mh316.org/bible-studies/the-god-of-new-beginnings
    Pass: myrtlefield
    I asked a question about slow loading images, but no response. I think I figured the issue is my accordion script. It seems that when it is active, SQ loads the Markdown Accordion box before the image at the top of my page. This makes it look like the page is very slow. However, if I add 'defer async' to the Custom Code JavaScript, the Accordion function doesn't load at all!
    Working code with slow image load:
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script>
        $(document).ready(function(){
        $('.markdown-block .sqs-block-content h1').addClass('ui-closed').css('cursor','pointer');
        $(".markdown-block .sqs-block-content h1").nextUntil("h1").slideToggle();
        $(".markdown-block .sqs-block-content h1").click(function() {
          
          $(this).nextUntil("h1").slideToggle();
          $(this).toggleClass('ui-closed ui-open');
          });
        });
    Not working code with fast image load:
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" defer async></script>
    <script>
        $(document).ready(function(){
        $('.markdown-block .sqs-block-content h1').addClass('ui-closed').css('cursor','pointer');
        $(".markdown-block .sqs-block-content h1").nextUntil("h1").slideToggle();
        $(".markdown-block .sqs-block-content h1").click(function() {
          
          $(this).nextUntil("h1").slideToggle();
          $(this).toggleClass('ui-closed ui-open');
          });
        });
×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.