Coder Social home page Coder Social logo

lenamax2355 / vanilla-js-single-page-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from managervcf/vanilla-js-single-page-app

0.0 0.0 0.0 28 KB

Single Page App built with vanilla JavaScript.

Home Page: https://vanilla-js-single-page-app.netlify.com/

HTML 7.71% JavaScript 92.29%

vanilla-js-single-page-app's Introduction

VanillaJS Single Page App

The goal of this project is to create a Single Page Application without using any frameworks or libraries. Just pure JavaScript.

Project focuses on three main aspects:

Router

The core idea behind the router is the use of the hash # symbol in the URL. Whenever browsers hit this character in the URL, they skip everything after it by default. From a browser's perspective localhost:8080/#/nowhere and localhost:8080/#/somewhere are the same and it will not send a server request to fetch the serverside route. This creates a possibility to create a Single Page App quite easily. The router compares the part of the URL after # against defined routes and renders a corresponding page.

Templates

Templates are constructed via ES6 template string literal syntax. All templates have a render method that is called when a page matches visited URL. The render method is asynchronous in order for the page to fetch data from external sources when needed.

Structure

The index.html invokes index.js and is told that the app structure is modularized via type="module" attribute. The index.js contains the core logic and binds all of the pieces together.

The app consists of components and pages, both included inside views directory. The components are pieces of HTML that are visible regardless the URL. The pages are rendered depending on the URL we visit. They should include the main content.

Development

As there are no dependencies used, there is no need to install anything. Just type npm run dev in your command line to run the app. As simple as that.

The npx live-server --verbose command hidden under the npm run dev script will execute the app for you using live-server. It will open the app and watch it for changes.

By default, the app is hosted at port 8080 unless specified otherwise. Open http://localhost:8080 to view it in the browser.

Production

The app is deployed using Netlify, view it here.

vanilla-js-single-page-app's People

Contributors

managervcf 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.