Support lazy integration of scripts
-
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 afterDOMContentLoaded
.
- The topic ‘Support lazy integration of scripts’ is closed to new replies.