Comparison of import vs <script> tag

Viewed 662

Are there any benefits (e.g. performance, speed etc) between import and <script> tag for shared code inclusion in the following basic (non-library) examples?
What are the pros/cons?

via <script> tag

// common.js
class SomeClass {
 // code 
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Popup</title>
  </head>
  <body>

  <!-- HTML -->

  <script src="common.js"></script>
  <script src="popup.js"></script>
  </body>
</html>

via import

// common.js
export class SomeClass {
 // code 
} 


// popup.js
import {SomeClass} from './common.js'
0 Answers
Related