Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Embedded code not loading when page loads


To begin I must say I have no real experience coding, so if you need more information or something different, please ask! 

I have been using three different third party widgets (like affiliates or hover maps) and have been injecting their code into the website. My problem is when you load the website, the things with code don't load until you refresh the page. 

Example 1: On the home page, there is supposed to be a map that shows up before the slide gallery underneath it. If you hit refresh the map shows up, but it doesn't show up when you first go to the page. 


Example 2 & 3: Here on the product page I want to have the affiliate links work under Book Your Activity or Book Your Accommodation. Again, they only work when you refresh the page. Is there something I can do from my Squarespace editor or is this something wrong with all of the code?


Here is the code for Booking.com for example:

<ins class="bookingaff" data-aid="1890417" data-target_aid="1890417" data-prod="map" data-width="100%" data-height="590" data-lang="ualng" data-dest_id="0" data-dest_type="landmark" data-latitude="43.7679178" data-longitude="11.2523792" data-landmark_name="Cape Town" data-mwhsb="0" data-address="Cape Town">
    <!-- Anything inside will go away once widget is loaded. -->
        <a href="//www.booking.com?aid=1890417">Booking.com</a>
<script type="text/javascript">
    (function(d, sc, u) {
      var s = d.createElement(sc), p = d.getElementsByTagName(sc)[0];
      s.type = 'text/javascript';
      s.async = true;
      s.src = u + '?v=' + (+new Date());
      })(document, 'script', '//aff.bstatic.com/static/affiliate_base/js/flexiproduct.js');

Thank you in advance!!

Share this post

Link to post

3 answers to this question

Recommended Posts

  • 0

The summary is, basically, to wrap your code like this:

  window.Squarespace.onInitialize(Y, function() {
    //Your code here...

If a response helped you out, send a 'Like' 👍 (bottom-right) and/or 'Upvote' vote.jpg.c260784ece77aec852b0e3049c77a607.jpg (top-left)

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

  • Create New...