GithubHelp home page GithubHelp logo

l.js's People

Contributors

alexgal0 avatar fossabot avatar ivanrey avatar malko 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

l.js's Issues

[RESEARCH] Page-based loading

There are a lot of JS loaders, really. But none of them, at least within documentation, addresses a problem I'm eager to solve. That is to use single <script> line per whole project which inits page-based loading of dependencies.

Let's create a simple project with index, portfolio, and contacts pages.

Microframework will help us with routing:

$app->get('/portfolio/',
    function () use ($app) {
        $prices = array(
              "price_mine"  => "90",
              "price_rival" => "120"
        );
        $app->render('portfolio.twig', $prices);
    })->name('portfolio');

Template engine will help us with rendering:

{% extends "base.twig" %}
{% block content %}
     <p>Aren't you sick and tired to pay {{price_rival}}…</p>.
{% endblock content %}

And the missing part in every page is <script src="/static/init.js"></script> that works as follows

  • all pages load jQuery from CDN or from my server as fallback,
  • index loads SoundManager to serve audio salutation,
  • portfolio loads Lightbox to serve images,
  • contacts loads Forms validator.

What's the best way to achieve it?
And how to do that with l.js whether it's possible?

Thank you in advance.
Warm regards from Russia, Alexander.

Npm registry

Hi, @malko
We are having trouble trying to import l.js, the versions are getting messed up because the bower.json is not updated, it would be helpful if you could register l.js in npm in order to clarify the versions.

Greetings, Marlon.

Disabling an already loaded css file

Is it possible to disable a CSS file that was loaded by l.js?

When I load css files in traditional way, without l.js, I currently use this method to disable a specific one:

// To disable a specific css file
document.getElementsByTagName('link')[2].disabled = true
// And, to enable it again
document.getElementsByTagName('link')[2].disabled = false

Is there a way to accomplish this with l.js?

l.js busts itself, and the vm.

I am embedding the l.min.js script directly into the document by using PHP. The script is stored in an in-memory cache and embedded into the page, then served. At least, that is what I wanted to do. But it seems that gEval is being called over, and over, and over - untill it causes an error:

Uncaught RangeError: Maximum call stack size exceeded

Could you look into this? Thus far, l.js seems to be the smallest loader that supports "bundles" (i.e. combining a few things into one name)

Kind regards!

Add Bower support

It would be very nice to have a bower.json to be able to install ljs without using the github URL, also to control versions. Also jsdeliver would be a nice option to have.

Uncaught TypeError: appendElmt is not a function

It seems that after switching to appendElmt instead of gEval there is an scope issue.

Since the var .... appendElmnt is inside an if the variable isn't actually available at the return line (149) thus causing an error in the console>

Uncaught TypeError: appendElmt is not a function

There are several ways to fix it. I just sent a Pull Request with one, but feel free to dismiss it and change it to your own preference.

Apply doesn't work to user arguments array ?

Hello,

I tried to load multiple css files one by one with a table but the apply doesn't seams to work with a case like thie:

cssUrls = [ "http://../first.css", "http://../second.css" ];
ljs.load.apply(null, cssUrls);

I got this error with Firefox:

TypeError: this.loadcss is not a function
...pply(this,t)}return t.match(/\.css\b/)?this.loadcss(t,e):this.loadjs(t,e)},y={},...
-------------------------------------------^

I have the same kind of error with JavaScript files as urls. Is there an another way to load files one by one from an array ? (v0.1.1)

Enhance error handling

as describe in issue #14, find and implement a way to allow for better error handling (using a callback instead of a fallback)

fail case

Hi,
Incase of any failed resources (dont exist, path incorrect), how can i capture that ? I only see load function.
is there a fail function so i can do something like .load().fail()

I want to use it with aliases method ..

Retry support

Hi Malko,

I added a retry support to my version of l.js. It basically uses the #id part of the url to give a second url and in case the script fails to load it will retry with the #id url.

For us is helpful since we use a lot of CDNs and some are blocked in internal clients, so this way we can fallback to the local version of the file.

I don't know if you're interested in adding this support. It certainly needs review and I would like to make it optional also (maybe with the same mechanism as checkLoaded?)

Async attribute

I was wondering if l.js should add the script tags with the async attribute.

We use it to load all our stack , specially because of the dependency management we obtain. But since script tags are generated in the head, maybe the async would help speed up the rendering.

Any thoughts?

progress Handling, compatibility with Pace.js

Hi,
Is it possible to get progress of loaded content ?
I am trying to use pace.js with l.js but it does not work.

I have lots of assets and I need to display progress as just showing busy-spinners dont give information to users on how much is loaded and how much remaining.
Something like

ljs
.addAliases(aliases)
 .load('all-assets',function(){ /* your callback here */}) 
 .onProgress( function(value,total ){ /* could display progress here in percentage */}) 

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.