fabiospampinato / cash

An absurdly small jQuery alternative for modern browsers.
MIT License
6.97k stars 272 forks source link

NewBie - $(document).ready(function() { } ); in Cash ? #339

Closed marcoczen closed 4 years ago

marcoczen commented 4 years ago

Hi,

In JQuery, to ensure DOM is ready before we run scripts, we use;

$(document).ready(function() { some code here } );

In Cash how do we do this ? Like -> https://github.com/fabiospampinato/cash/pull/4 ? Dont seem to see this in the doc. Sorry.

Note - new to cash. Came here after noticing that zepto is 'dead' and the fork is also 'dead'. This project seems actively maintained. Great job.

limonte commented 4 years ago

In JQuery, to ensure DOM is ready before we run scripts, we use;

$(document).ready(function() { some code here } );

In Cash how do we do this ?

Sure: https://github.com/fabiospampinato/cash#fnready-

fabiospampinato commented 4 years ago

You can just write: $(function() { some code here } );, it works the same and it's a bit cleaner.

marcoczen commented 4 years ago

Thank you.

So ...

$(document).ready(function() { some code here } );
$(function() { some code here } );

Thank you. Got it.

fabiospampinato commented 4 years ago

Yes 👍 As a rule of thumb you can just use jQuery's docs instead, which are much better: https://api.jquery.com/

marcoczen commented 4 years ago

Thank you.