javascript - jQuery page structure best practices for use of $(document).ready(function(){}) -


I currently have a lot of widgets on my website which are all kinds of jquery functions, animation, AJAX calls etc. It is a good practice to read online that you try to bundle your JS in a file, when you understand it or say that each of my widgets is widely used on my website, it seems like That's all for these widgets Files / javascript to be put in a file. Now, if I have $ (document) .ready (function () {}) I want to open a widget button for each, automatically loads some data when preparing a doctor, etc. . What would be the best practice to do this? Not every widget is on every page, so if everything is in a javascript file, will non-existent non-existent elements be able to practice poorly?

I think I'm really having trouble viewing the best method of my structure to provide the best performance jquery / javascript around my web application < P>

JS is very good to keep the file filled with reusable code, so all your functions load all the pages in one page Use .js as that file. Then every page Specific execution is required, I open the tasks that do specific functions on that page, inside a doctor at the bottom of the page.

In this way you are only doing what you need per page. In any case, you should try to do things that your actions are included in the default .js file instead of a special JS file which is completely included for the entire site. is.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -