Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ready function request #18

Closed
khaledmndev opened this issue May 17, 2022 · 3 comments
Closed

ready function request #18

khaledmndev opened this issue May 17, 2022 · 3 comments

Comments

@khaledmndev
Copy link

First i would like to thank you for this awesome library you developed :)
Second this is not an issues actually it's a feature request..

i would like to see "Selector.ready()" feature in the upcoming build.

$(window).ready(function() {
//Do Something
}) 

Regards..

@mcqua007
Copy link
Owner

mcqua007 commented May 17, 2022

Would you mainly be using this like the old jQuery way. As your example shows ? Essentially waiting for the DOM to be loaded in order to start manipulating the DOM. My goal is to keep the library as small as possibly. I think this is a useful add, but I am wondering if I can just let people import as a separate module. Which would have a different syntax.

import { $, ready } from 'quantdom'

ready(window).then(()=> {
//do something after the dom has loaded
 $('.some-el').text('Look at me mom, the DOM is loaded!!!')
});

//or even just (a function I already have)
import { $, docReady } from 'quantdom'
docReady(() =>{
//do something after the dom has loaded
 $('.some-el').text('Look at me mom, the DOM is loaded!!!')
})

By not making this part of the Quantdom class. I can make this tree shakable. Do you see any reason something like this wouldn't work or do you think you need it be part of the Quantdom instance i.e. $(window).ready() ? If so please explain ? I am open to either or but again the benefit of making a separate function is tree shaking in order to keep over all library low.

My though is to start doing this for additional features or make some type of plugin system in order to keep the core Quantdom super small but extendable where needed!

BTW Thanks for your feedback! Really appreciate it!

@khaledmndev
Copy link
Author

Your Above Suggestion or example is really useful as well, thanks :D

@mcqua007
Copy link
Owner

Your Above Suggestion or example is really useful as well, thanks :D

I added it to version 1.2.8. I may change it in the future and it works differently than jQuery.

   $().docReady(function(){
      console.log('DOM READY')
     //do all your DOM stuff here
    })

Passing in an element i.e. $(window).docReady(); doesn't do anything. This may change in the future or I ay pull the docReady function outside of the instance like I stated in my post above. But version 1.2.8 will have it.

https://cdn.jsdelivr.net/npm/quantdom@1.2.8/dist/quantdom.min.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants