Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting with Javascript - framework?

Tags:

javascript

I don't know much Javascript - just little of core language, but that can be learnd - no problem. I want to get started writing simple demo animations/games with canvas.

What I'm not sure about is correct ways of embedding Javascript in pages to make resonably cross-browser (say without IE). Should I just start with vanilla JS or use some framework like JQuery from start which can help me shorter code and cross-browser?

Or will starting with framework will make me understand less details of JS itself?

like image 959
zaharpopov Avatar asked Dec 17 '22 03:12

zaharpopov


1 Answers

Use a framework like jQuery. You don't learn anything particularly insightful by struggling with the somewhat baroque, inconsistent, and incompatible APIs that jQuery (or any other decent framework) abstracts over. You'll still be using the same language, you'll just be using nicer, more portable APIs on top of it.

As you get more experienced, you'll find situations that your framework doesn't cover, or in which you need to extend your framework. At that point you can start dealing with the actual APIs that the browsers expose, and the incompatibilities and inconsistencies that dealing with them entails.

For very simple noodling around with <canvas>, you can frequently get a way with raw JS without too much trouble, as the browsers that support canvas also tend to be more consistent with each other (though the APIs will be a lot clunkier than what jQuery provides). Of course, you could use excanvas for <canvas> emulation IE, at which point you have to deal with the incompatibilities again.

like image 67
Brian Campbell Avatar answered Dec 28 '22 02:12

Brian Campbell