• Resolved loilo

    (@loilo)


    I’m working as a developer for an agency, and we’re using the Spotlight Instagram feed on a customer’s website.

    Since the plugin loads data from Facebook servers (not much, just the account’s avatar, but still), we will need to block the feed from showing by default in the future, until a visitor consents (privacy policy reasons, yada yada).

    While blocking the Spotlight scripts through WordPress mechanisms works, loading them later won’t.

    The technical reason for this is that the Spotlight script reacts to the DOMContentLoaded event, which only fires once — and if the script is loaded after that, it will just do nothing.

    It would be really great if an additional check to the document.readyState could be done to make the script work even if it is included after DOMContentLoaded.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Yep, I have the same problem! Please fix this! It should only be a few lines of code; something like this:

    // https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState
    if(document.readyState !== 'complete') {
    	// DOMContentLoaded has not fired yet, wait for it
    	document.addEventListener('DOMContentLoaded', initFeed);
    } else {
    	// DOMContentLoaded has already fired, init plugin directly
    	initFeed();
    }
    Plugin Support Hendra Setiawan

    (@hendcorp)

    Hi @loilo

    You can achieve this by using Spotlight’s?Javascript API?and use?SpotlightInstagram.init()?to re-initialize the feed later (after the visitor clicking the consents button).

    I hope it helps. Please let me know if you have any other questions.

    Thread Starter loilo

    (@loilo)

    Thank you! I think that is something we can work with. ??

    Plugin Support Hendra Setiawan

    (@hendcorp)

    Great! Thank you @loilo

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Support lazy integration of scripts’ is closed to new replies.