官术网_书友最值得收藏!

Sharing and reusing JavaScript

While you develop web applications, you will always end up doing the validations for your UI, both at the client and server sides, as the client-side validations are required for better UI experience and server-side validations are needed for better security of the app. Think about two different languages in action: you will have the same logic implemented in both the server and client sides. With Node.js, you can think of sharing the common function between server and client, reducing the code duplication to a large extent.

Ever worked on optimizing the load time for client-side components of your Single-Page Application (SPA) loaded from template engines such as Underscore? You would end up thinking about a way we could share the rendering of templates in both server and client at the same time; some call it hybrid templating.

Node.js resolves the context of duplication of client templates better than any other server-side technologies, just because we can use the same JS templating framework and the templates both at server and client.

If you are taking this point lightly, the problem it resolves is not just the issue of reusing validations or templates on the server and client. Think about an SPA being built; you will need to implement the subsets of server-side models in the client-side MV* framework also. Now, think about the templates, models, and controller subsets being shared on both client and server. We are solving a higher scenario of code redundancy.

主站蜘蛛池模板: 永昌县| 当雄县| 河间市| 高州市| 德格县| 易门县| 苍梧县| 台州市| 同江市| 耿马| 灵石县| 错那县| 新田县| 浙江省| 师宗县| 阜南县| 宁波市| 扶绥县| 新乐市| 绍兴县| 濮阳县| 伊吾县| 光泽县| 长白| 台州市| 偃师市| 嘉义市| 东海县| 九龙县| 京山县| 扶风县| 舒城县| 临沂市| 万载县| 休宁县| 梅河口市| 竹溪县| 江北区| 贵阳市| 揭阳市| 泸溪县|