A few days ago, I saw an alternative way to use functions in jQuery event bindings. It consists of: first declare a function, and then call it a binding, as shown below. I think the code remains more organized.
//Função para capturar e passar os elementos para a função de apply. function invokeSequentialFade(){ //code... }; //Função para Instanciar o carousel de acordo com o dispositivo. function invokeCarousel(){ //code... }; //Função para instanciar o scrollfade (elementos surgirem no scroll). function invokeScrollFade(){ //code.. }; //Fixando a navbar no topo, caso o usuário não esteja na Home. function manipulateFixedNavbar(){ //code... }; /************ END - Declaração de funções ***********/ $(window).on("resize",invokeCarousel); $(window).on("resize",manipulateFixedNavbar); $(window).on("resize",invokeSequentialFade); $(document).on("scroll",invokeScrollFade);
I did not find an article explaining if this is good practice.
I doubt: could it be harmful? I also have downloaded AJAX content on my page, so I don’t know if this method affects the application in any situation.
source share