How to organize javascript on the front-end w/o using server technologies? -


i'm working on front-end javascript project follow characteristics:

  1. performance not matter
  2. lots of classes
  3. client only.

the third point main reason asking question when research how organize javascript on client side answers include server-side library. not have access this. keep classes in 1 folder (maybe sub-folders), main script, , folder 3rd party libraries. haven't found way of doing nicely however.

i've tried in 1 html file this:

<!-- include 3rd party libraya --> <!-- include 3rd party librayb --> <!-- include classa script --> <!-- include classb script --> <!-- include main.js --> 

but main.js didn't seem know classes were.

ideally i'd require but, again i've found similar uses server side tech can't use.

here reduced form of tried:

./index.html:

<!doctype html> <html> <head>     <title>test</title>     <script type="test/javascript" src="./classes/testclass.js"></script>     <script type="text/javascript" src="./script.js"></script> </head> <body>  </body> </html> 

./script.js

var testclassinstance = new testclass("test!"); testclassinstance.bar(); 

./classes/testclass.js

var testclass = function (foo) {     this.foo = foo; };  testclass.prototype.bar = function () {     console.log(this.foo); } 

the error got was:

script.js:1 uncaught referenceerror: testclass not defined(…) 


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -