How difficult are it to create a JavaScript framework?

Source: Internet
Author: User

Share an article from Quora https://www.quora.com/How-difficult-is-it-to-create-a-JavaScript-framework

This mostly depends in your JavaScript skills, but as you said, that's the using a lot of JavaScript it won ' t is that di Fficult ...

There is different words:
Library: is a script, which supports you by completing some task (s)
Framework: Takes over everything and helps-to-build the application from the first line of code till it's finished and creates L Ifecycles etc.

Creating the JavaScript Framework itself isn ' t that a difficult task. A much more difficult task though, was the design, you has to do before you actually start building the Framework.

Let's think, what would the perfect JavaScript Framework is like?

  • Easy-to-use
  • Includes a router using the new HTML5 pushstate function
  • Have it ' s own easy-to-use template engine, that also can load templates from the server
  • Loads models easily automated from the server when requested
  • Makes it easy-modularize the Controllers, that is used
  • Has it's own Message Bus System to easily trigger events (as well events of the Framework as events triggered by the Frame Work user)
  • Gives easy access to Cookie Setting and Server communication (including Sockets)
  • Can save models on the client side with HTML5 database and filesystem features
  • Caches Some server requests if told so (or even automated with some intelligent algorithm, to check whether a good idea to Cache or not)
  • Makes it as easy as possible to create One-page-apps
  • Easy-to-use together with the PHP Laravel framework or the node. JS Express Framework (sorry Ruby, I don t like you:))
  • Easily extendable
  • Have a life cycle, so that is able to complete tasks before/after the Page Rendering/model loading/unload etc.
  • Open Source
  • Compatible with most important JS libraries
  • Well documented (the most important thing @ all and yes I know writing documentations are quite boring:))


There is approaches for creating any kind of apps:
the Model View Controller approach (MVC):
(Source: http://www.wikipedia.de)
This approach consist of Model Objects, which stores all the data of the application, views that define how the data should be viewed and Controllers, which  Yes, guess is right-controllers the views and Models, and define, when which function have to is executed.
An example for this type would is backbone.js (although Backbone.js defines itself much more as a library than a frame Work)
and there are the Model View ViewModel approach (MVVM):

(Source:  http://www.wikipedia.de)
Here are the Data bindings:for example you can bind a variable to a special <p> tag. E Very time the Variable get ' s updated the paragraph would be updated as well.

I Personally prefer the MVC approach, as it makes it a lot easier to create ONE-PAGE-APPS, as you don ' t simply bin D your variables to one element on the Html-source, which makes it possible to has different UX types in your main conten T a lot easier.

Now here I'll give you some tips for the design&building process:

    • only use the one global namespace for your whole Framework, this also makes it easier to being compatible with other Li Braries
    • Draw up all your objects on a paper (yes real paper it still exists and was a pretty good option for this ), so your always has a overview about what classes you have, which ones still is missing etc.
    • Pack The whole thing in a require.js module
    • use other libraries as a base for your framework (If it's about being productive and not doing it for the craic you D On ' t has to reinvent the wheel)
    • always has a list of bugs and new features next to you, and mix the different Things you still has to do (don't just fix bugs for one day, which could be too boring and would make you loose the Enthusi ASM)
    • never GIVE up!

There is a lot of frameworks out there and if you had the time to build your own what should do it-you would learn a lo T if you don't.
And the more fun you have building it's the less hard the work it's going to being for you.
Alright I hope I was able to help you out if you had further questions don ' t bother to ask:)

How difficult are it to create a JavaScript framework?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.