-1

I basically want the equivalent of Java "import" statement in JavaScript.

I am working in a pure JavaScript environment (no HTML).

I have looked at this question but I don't want to use external libraries like JQuery or RequireJs.

My usecase: I want to import the tv4 js validation library

Community
  • 1
  • 1
amey91
  • 542
  • 6
  • 17

1 Answers1

0

For now, this isn't possible with current ECMA-Script 5.x implementations. For now, you can look forward for the new ECMA-Script 6 (ES-Harmony) standard which provides native module loading without using third-party libraries.

Perhaps you want to download working drafts of next standard here or check some blog post like this that explains how this is going to work in the near future.

In addition, you can implement what RequireJS has already implemented from scratch in order to avoid adding third-party code to your project, but maybe you can avoid wasting your time re-inventing square wheels and adopt what other have already done!

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206