osclass / Osclass

With Osclass, get your own classifieds site for free. Build your own Osclass installation and start advertising real estate, jobs or whatever you want- in minutes!
http://osclass.org/
647 stars 343 forks source link

[IMPROVEMENT] Add .js & .css lazyloader #1439

Open emanwebdev opened 10 years ago

emanwebdev commented 10 years ago

Add a dependency-free tiny (966 bytes) JavaScript utility that makes it super easy to load external JavaScript and CSS files on demand.

https://github.com/rgrove/lazyload

AlaskanDesigns commented 10 years ago

nice..only a couple of fixes needed. I like the on demand part ;-)

emanwebdev commented 10 years ago

Quoted from https://github.com/rgrove/lazyload#caveats

All browsers support parallel loading of CSS. However, only (to be updated with nowadays browsers capabilities as stated in https://github.com/rgrove/lazyload/pull/27) Firefox and Opera currently support parallel script loading while preserving execution order. To ensure that scripts are always executed in the correct order, LazyLoad will load all scripts sequentially in browsers other than Firefox and Opera (to be updated with nowadays browsers capabilities as stated in https://github.com/rgrove/lazyload/pull/27).

This being said:

In browsers that don't preserve the execution order of asynchronously-loaded scripts, LazyLoad will safely load the scripts sequentially.

It looks to me like an easy & quick improvement to the actual osc_register_script() and osc_enqueue_script ?

smartey commented 10 years ago

I like it but wonder about 'cost' vs 'revenue', very wortwhile to try and see how it performs! Have you already tried to use this emanwebdev?

conejoninja commented 10 years ago

Hi, I'm not a native English speaker, but what I understood is that sequentially loading is only done in browsers NOT supported. In every other browser, it will load files async.

This could be a problem if one JS file depends on other (like a jQuery plugin).

I would need to test how this will work.