GithubHelp home page GithubHelp logo

iekumdario / hnpwa-vanilla-base Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cristianbote/hnpwa-vanilla

0.0 1.0 0.0 852 KB

Hacker News PWA implemented using no framework just javascript

Home Page: https://hnpwa-vanilla.firebaseapp.com/

License: MIT License

JavaScript 50.12% HTML 49.88%

hnpwa-vanilla-base's Introduction

Plain Javascript(no framework) Hacker News Example

See this application live at: https://hnpwa-vanilla.firebaseapp.com

This is an example of a PWA built using no framework for view manipulation just Webpack for bundling and service worker. Do think of this as the way to build your application using no framework - my 2 cents.

Made with โค๏ธ in Cluj-Napoca, Transylvania ๐Ÿฐ

Icons made by Freepik Freepik from www.flaticon.com is licensed by CC 3.0 BY

Installation

  1. Clone the repo
  2. Run npm install
  3. Run npm run dev and would spun up a server locally and watch

Details

I've built this as an experiment to see if, native/vanilla javascript, can beat the PWA scores on https://hnpwa.com/ As soon as I finish the implementation, I'd be posting the Lighthouse report. Things are going so good so far. There are a couple of thing that I had to do, in order to make it speedier. Check it out!

Component based composition

So, we must acknowledge the path that React opened, for view composition, moving the composition part in javascript, leaving you focused on what exactly you'd like to accomplish.

Therefore, my take on the composition was pretty straightforward with a React-like approach, but using the native dom-api.

So a component would look like

import { div, a } from '../core/dom-api';

export const myCustomNavigation = (props) => {
    return div(
        { className: 'my-custom-navigation' },
        [
            a({ href: '/' }, 'Home'),
            a({ href: '/about' }, 'About'),
            a({ href: '/contact' }, 'Contact')
        ]
    )
};

As you can see, it's pretty darn similar to React/Preact and the bunch. There's no magic happening behind the scene. If you peek inside ./core/dom-api.js you'll see that everything is split and there's just one createElement function, which returns a function that will actually create the component based on the params given: props, and content.

I'll let you explore more. :)

Feedback welcomed!

Feel free to drop a line, file an issue and so on. Much appreciated!

hnpwa-vanilla-base's People

Contributors

cristianbote avatar kresnasatya avatar gersongams avatar iekumdario avatar velusgautam avatar starchturrets 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.