Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

inline javascript modules

<script type="module" data-info="https://stackoverflow.com/a/43834063">let l,e,t
='script',p=/(froms+|imports+)['"](#[w-]+)['"]/g,x='textContent',d=document,
s,o;for(o of d.querySelectorAll(t+'[type=inline-module]'))l=d.createElement(t),o
.id?l.id=o.id:0,l.type='module',l[x]=o[x].replace(p,(u,a,z)=>(e=d.querySelector(
t+z+'[type=module][src]'))?a+`/* ${z} */'${e.src}'`:u),l.src=URL.createObjectURL
(new Blob([l[x]],{type:'application/java'+t})),o.replaceWith(l)//inline</script>

<script type="inline-module" id="utils">
  let n = 1;
  
  export const log = message => {
    const output = document.createElement('pre');
    output.textContent = `[${n++}] ${message}`;
    document.body.appendChild(output);
  };
</script>

<script type="inline-module" id="dogs">
  import {log} from '#utils';
  
  log("Exporting dog names.");
  
  export const names = ["Kayla", "Bentley", "Gilligan"];
</script>

<script type="inline-module">
  import {log} from '#utils';
  import {names as dogNames} from '#dogs';
  
  log(`Imported dog names: ${dogNames.join(", ")}.`);
</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript formate date 
Javascript :: byte number to array js 
Javascript :: google autocomplete not returning lat long 
Javascript :: blur js 
Javascript :: redux toolkit remove from array 
Javascript :: how to load js in vuejs components 
Javascript :: usehistory() hook 
Javascript :: javascript set cookie 
Javascript :: jQuery DataTables Checkboxes 
Javascript :: ng select2 angular dropdown 
Javascript :: find all of array which satisfy condition javascript 
Javascript :: get previous link javascript 
Javascript :: how to avoid duplicate values in dropdownlist using jquery 
Javascript :: split and join in javascript 
Javascript :: how to add objects in array 
Javascript :: datatables keep order and page selection page refresh 
Javascript :: javascript substring 
Javascript :: node.js parameters 
Javascript :: show modal by using id in list react 
Javascript :: filter out arrays js 
Javascript :: byte to integer js 
Javascript :: js slice string at word 
Javascript :: alpine js open outside div 
Javascript :: js naming conventions 
Javascript :: javascript replace tag 
Javascript :: pass props in compound component 
Javascript :: vue store access state in actions 
Javascript :: vue directive 
Javascript :: curl post request 
Javascript :: angular multiselect dropdown 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =