A component that takes a plain text field with script tags and script links and parses
html: The markup coming from the CMSshowLoading: When true, shows "Loading" on the front end while the external scripts are loading.
import Embed from '@bkwld/vue-embed'
Vue.component 'embed', Embedvue-embed(:html='your_html_here')vue-embed solves the problem of script tags not executing on client-rendered pages. Often these same script tags execute normally when the page is loaded via SSG. A common scenario for this is a CMS with an Embed Block that renders script tags to the front end, such as embedded videos or publisher tags.
- On SSG and SSR,
vue-embedrenders the provided HTML code with thescripttags removed. - On
mounted,vue-embedfinds allscripttags with external URLs and appends them to the document head withasync="true" - On
mounted,vue-embedfinds allscripttags with inline code and executes them usingeval().