Giter Site home page Giter Site logo

louwii / vue-static-page-experiment Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 2.19 MB

Experimenting Vue on a static page with components spread across the page

Home Page: https://louwii.github.io/vue-static-page-experiment/

JavaScript 12.16% HTML 30.98% Vue 56.86%
vue vuejs experiment async javascript

vue-static-page-experiment's Introduction

vue-static-page-experiment

What is this about? I wanted to try and use Vue to replace the old jquery way of doing things, where you have your HTML page generated, and jquery plugs into some part of the HTML to do its thing (you know, stuff like $(".expander").expander()).

I wanted to see if this is even worth it, if it's easy/easier than jQuery, how light/heavy it is, etc.

One of the biggest advantage right out of the box is having the power and features that Vue offers, which I consider way better than what jQuery offers. It's also worth mentionning jQuery is 30kb minified gzipped. You'll see below Vue is barely over.

Production build

Async

The async production build generates 5 js files.

  • async.xxxxx.js - 3.77 KiB (1.70 KiB gzipped)
  • chunk-vendors.xxxxx.js - 111.56 KiB (40.55 KiB gzipped)
  • chunk.xxxxx.js - Vue Component (Counter) - 1.67 KiB (0.83 KiB gzipped)
  • chunk.xxxxx.js - Vue Component (Expander) - 1.50 KiB (0.79 KiB gzipped)
  • chunk.xxxxx.js - Vue Component (Modal) - 28.53 KiB (8.58 KiB gzipped) - Bigger because it contains a third party library for modals (vue-js-modal), imported directly in the component code, so not included in chunk-vendor

We only need to include async.js and vendors.js in the HTML page, the components are loaded asynchronously by the browser when Vue asks for them. And Vue asks for them only if it needs them.

Check out the 2 async examples.

Both use the exact same JS code. The only difference is the HTML async.html source async2.html source. Async2 does not have a modal in its HTML. If you look at the files loaded in both example in your browser network tab, you'll see async2 is not loading the js chunk for the modal.

Project setup

npm install

Compiles and hot-reloads for development

npm run serve

Compiles and minifies for production

npm run build

Run your tests

npm run test

Lints and fixes files

npm run lint

Customize configuration

See Configuration Reference.

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.