GithubHelp home page GithubHelp logo

Comments (4)

lekoala avatar lekoala commented on May 15, 2024 1

In my setup, I've settled for using defer instead of async for that reason : at least I get a predictable loading order. It's even actually more efficient to do it that way (this article has some great explanations : https://flaviocopes.com/javascript-async-defer/#tldr-tell-me-whats-the-best)

When using defer, plugins will be loaded before and can be discovered easily. In the case of the jQuery plugin, you will have registered anyway a $.fn.filepond namespace, that you can use to declare the plugins as well.

And if everything is bundled together, load order is also predictable.

So, to summarize : with defer or bundles, you will have a predictable load order that removes the necessity to manually registering the plugins.

What do you think?

from filepond.

rikschennink avatar rikschennink commented on May 15, 2024

I did initially set it up like that. But when using async script tags this gets a lot harder.

Ideally, I would like the plugins and the core to find each other without polluting the global scope, so plugins fire a pluginloaded event and filepond fires a filepondloaded event ( both on the root element of the document ), then plugins can automatically register by listening to the filepondloaded event and filepond can automatically register plugins by listening for pluginloaded events. Problem is, you don't know if all plugins have loaded because there's no information on how many need to register.

So while this works when putting the script tags after the filepond tag it only does when all code is loaded in synchronously.

I'm all ears for a possible solution, but that's the reason why plugins are registered manually because then it doesn't matter and it's up to the dev to make sure everything is loaded before registering.

from filepond.

rikschennink avatar rikschennink commented on May 15, 2024

What a clear and concise article, love it.

I think using defer is a great approach, will see if I can add this in the near future. registerPlugin would still be useful for devs loading async or using the modules ( without global scope pollution ).

from filepond.

rikschennink avatar rikschennink commented on May 15, 2024

Added this to the roadmap so will close for now.

from filepond.

Related Issues (20)

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.