Coder Social home page Coder Social logo

newbrain.js's Introduction

I coded this to demonstrate how router in backbone.js can be used in both frontend and backend.

A few years ago,(Not anymore), Google did not index dynamic content well from SPA(single page app) while it indexes static pages fine. The goal of this demonstration is to serve the initially requested page as static page while any further pages are populated dynamically using a single code. In genearl, you would need to make two separate codes - A static page from backend script and dynamic page from frontend script. As backbone.js(frontend) and express.js(backend) are both written in javascript, I could make a rounter in backbone.js run in express.js. Even if Google now indexes dynamic contents well, this could be still benefitial for a page load speed. You would experience that SPA often slow to load the initial page as it load both non-content resources and content throught Ajax calls. With the approach here can serve the page content in the actual HTML page rather than loading through Ajax, which would improve an initial page load speed.

In addtion to this, I had to make a new plugin for EJS because EJS does not support recursive include in browser while it supports it well in node.js(backend). The EJS plugin can be found here.

This code is not fully functional, and is coded only for demonstration purpose.

Install dependencies:

$ cd . && npm install

Run the app:

$ DEBUG=newbrain:* npm start

With Nodemon

DEBUG=newbrain:* nodemon ./bin/www

Build frontend code

npm run buildclient which is same as browserify backbone/newbrain/main.js -o server/public/js/newbrain/main.min.js

npm run watchclient which is same as watchify -d backbone/newbrain/main.js -o server/public/js/newbrain/main.min.js

newbrain.js's People

Contributors

devrama avatar

Stargazers

 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.