Git Product home page Git Product logo

wildhaber / gluebert Goto Github PK

View Code? Open in Web Editor NEW
190.0 10.0 6.0 1.42 MB

gluebert.js is a tiny helper lazy loading DOM Elements, StyleSheets and JavaScript files using dynamic import and code splitting

Home Page: https://gluebert.com

License: MIT License

JavaScript 96.86% HTML 1.67% CSS 1.47%
dynamic-import intersectionobserver mutationobserver observable-streams lazy-loading twig handlebars mustache critical-css

gluebert's People

Contributors

phanikandula avatar wildhaber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gluebert's Issues

Remove css when module is destructed

Description

Currently a once added css in the head will stay, even the module has been destructed. It should be removed from the dom when the last existing module is gone.

Initialize data subscription without a data-controller

Description

Since in the very basic data-controller it is mostly just an empty abstract extension. So this could be fast forwarded to have a controller automatically initialized, when no controller is given by default.

Something like:

import { DataSignature } from 'gluebert/data';

const SIGNATURE = new DataSignature('key.data');

export {
    SIGNATURE,
};

should become a valid data observable to key.data

Improve dependency management

Description

Currently it's a manual process within the controller to load further dependencies manually like:

    async _loadDependencies() {
        this._anime = await import('animejs');
    }

Example:
https://github.com/wildhaber/gluebert/blob/develop/documentation/themes/gluebert/src/js/modules/process-illustration/process-illustration.controller.js#L28-L30

It would be good to be able to define dependencies in the module signature and have them available in the controllers later.

Add viewport width & height conditions to modules

Description

When developing on a responsive website there are some elements that has to be cloned and used doubled - for example a navigation for the burger-style-menu on mobile and the mega-menu on a large screen.

Instead of loading both at once, what, if it would be possible to load a module only when a certain viewport width/height is valid, like:

import { ModuleSignature } from 'gluebert/module';

const NAVIGATION_MODULE = new ModuleSignature(`menu`, `.c-navigation`, { viewport: width: min: 123, max: 789 }, height: { min: 123, max: 678 }  })
    .setImportController(() => import('./navigation.controller').then((controller) => controller.NavigationController))
    .setImportStyles(() => import('./navigation.styles.scss'));

export {
    NAVIGATION_MODULE,
};

Create sleep, loading and ready flags to components

Description

As a developer I want to be able to create styling according to component's states.

For example:
sleep = the controller is ready to be attached as soon as the element appears within viewport
loading = the controller, stylesheets and dependencies are loading
ready = everything is bound successfully to the component (the controller must be able to overrule this)

All classes and it's appearance must be configurable in the options params.

Add basic cli-support

Description

As a developer I want to setup my modules, data and elements quickly with no hassle. For this reason it would be helpful to write some simple cli commands like:

gluebert create module slider

That builds a module structure like:

slider/
|-- slider.module.js
|-- slider.controller.js
|-- slider.styles.scss

or:

gluebert create data user

That builds a data structure like:

user/
|-- user.signature.js
|-- user.data.js

Do polyfill handling internally

Description

The current polyfill approach needs to be done at the loading level of the main JS-File like:

Example:

<script>
    var appElement = document.createElement('script');
    appElement.src = '/app.js';
    var scriptElement = document.createElement('script');
    if('MutationObserver' in window
        && 'content' in document.createElement('template')) {
        document.body.appendChild(appElement);
    } else {
        window.addEventListener('load', function() {
            scriptElement.src = 'https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.0.10/webcomponents-loader.js';
            document.body.appendChild(scriptElement);
        });
    }
    window.addEventListener('WebComponentsReady', function() {
        document.body.appendChild(appElement);
    });
</script>

See:
https://github.com/wildhaber/gluebert/blob/develop/documentation/themes/gluebert/layouts/partials/footer.html#L1-L22

This could be optimized and be done internally so developers only need to load the main script in their html - like:

<script src="/mysupercoolapp.js" async></script>

Demo throws error on several browsers

Description

The current 0.0.10-version throws errors on many browsers actually.
There are most probably issues with the documentFragment interpretator or IntersectionObserver.

Browsers

Safari Version 10.1.2

Throws errors :-)

Microsoft Edge

Don't load any component without error message in the console

IE11

Throws errors :-)

Screenshots

Edge:
0003screenshot

IE11:
0003screenshot

Safari:
bildschirmfoto 2017-09-13 um 17 42 33

Improve data-importer handling for DataObservable in DataSignatures

Description

Currently, within the data-signature you have to bind DataObserver manually like:

const SIGNATURE = new DataSignature(
    'balls.data',
    (dataPool) => {
        return import('./balls.data')
            .then((module) => {
                return new module.BallsData(dataPool);
            });
    },
);

Example:
https://github.com/wildhaber/gluebert/blob/develop/documentation/themes/gluebert/src/js/data/balls/balls.signature.js#L9-L13

It would be better to have a unified process like:

const SIGNATURE = new DataSignature(
    'balls.data',
    () => import('./balls.data').then((module) => module.BallsData);
    },
);

And gluebert will handle the instanciation.

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.