How does the JavaScript Import work under the hood? -


how import statement work in javascript? read documentation , says places exported code within scope of file. mean code copied on file type import?

for example - in library.js have:

export {export function getusefulcontents(url, callback) {     getjson(url, data => callback(json.parse(data))); } 

in main.js have:

import { getusefulcontents} 'library.js';  getusefulcontents('http://www.example.com',     data => { dosomethinguseful(data); }); 

this allows me call getusefulcontents() in main.js. question is, main.js have contents exported library.js?

is using import same having physically defined getusefulcontents() in main.js?

function getusefulcontents(url, callback) {     getjson(url, data => callback(json.parse(data))); }  getusefulcontents('http://www.example.com',     data => { dosomethinguseful(data); });  

the main reason why ask because want know if using import have effect on main.js file size? or else going on under hood?

thank you!


Comments

Popular posts from this blog

minify - Minimizing css files -

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -